PHP临时文件上载无效的图像资源
您好,我有一个用于调整图像大小的类(resizeManager.php): 但是我收到了这些错误PHP临时文件上载无效的图像资源,php,upload,image-manipulation,temporary-files,Php,Upload,Image Manipulation,Temporary Files,您好,我有一个用于调整图像大小的类(resizeManager.php): 但是我收到了这些错误 Warning: imagesx(): supplied argument is not a valid Image resource in resizeManager.php Warning: imagesy(): supplied argument is not a valid Image resource in resizeManager.php 我可以这样指向临时文件吗 谢谢 luc
Warning: imagesx(): supplied argument is not a valid Image resource in resizeManager.php
Warning: imagesy(): supplied argument is not a valid Image resource in resizeManager.php
我可以这样指向临时文件吗
谢谢
luca测试以下示例:
<form method="post" enctype="multipart/form-data" action="">
<input type="file" name="file" />
<div class="td" style="width: 100%; text-align: left;"><button type="submit">OK</button></div>
</form>
<?php
if( isset( $_FILES['file'] ) )
{
$img = file_get_contents( $_FILES['file']['tmp_name'] );
$image = imagecreatefromstring( $img );
echo imagesx( $image );
}
?>
好啊
测试以下示例:
<form method="post" enctype="multipart/form-data" action="">
<input type="file" name="file" />
<div class="td" style="width: 100%; text-align: left;"><button type="submit">OK</button></div>
</form>
<?php
if( isset( $_FILES['file'] ) )
{
$img = file_get_contents( $_FILES['file']['tmp_name'] );
$image = imagecreatefromstring( $img );
echo imagesx( $image );
}
?>
好啊
this->openImage做什么/返回什么?您能在原始帖子中发布openImage函数的代码吗(来自ResizeManager类)?tmp_name文件名为.tmp extension!所以在openimage函数$img中返回false!您需要使用实际文件名的扩展名,而不是临时文件名,因为正如Dawood所说,扩展名不同。$this->openImage做什么/返回什么?您可以在原始post中发布openImage函数的代码吗(从ResizeManager类)?tmp_name文件名是.tmp extension!所以在openimage函数$img中返回false!您需要使用实际文件名的扩展名,而不是临时文件名的扩展名,因为正如Dawood所说,扩展名不同。仍然告诉我无效的图像资源ImageSX接收图像资源,而不是文件名。仍然告诉我无效的图像资源ImageSX接收图像资源,而不是文件名。
<form method="post" enctype="multipart/form-data" action="">
<input type="file" name="file" />
<div class="td" style="width: 100%; text-align: left;"><button type="submit">OK</button></div>
</form>
<?php
if( isset( $_FILES['file'] ) )
{
$img = file_get_contents( $_FILES['file']['tmp_name'] );
$image = imagecreatefromstring( $img );
echo imagesx( $image );
}
?>