我正在尝试使用Jarrod's调整大小代码上传图片。 我面临的问题是,在从同一文件夹上传图像时,图像会完美调整大小。但是,当我从其他任何地方选择图像时,它会显示一组警告。我知道这可能是一个愚蠢的道路问题,但我无法纠正它。请帮忙!!
在HTML上传的代码是:
<form enctype="multipart/form-data" action="index.php" method="post">
<input type="file" name="image" />
<input type="submit" />
</form>
index.php上的resize代码是:
<?php
include_once("resize-class.php");
$fileVal1 = $_FILES['image']['name'];
$resizeObj = new resize($fileVal1);
$resizeObj -> resizeImage(500, 300, 'portrait');
$resizeObj -> saveImage('sample-resized.gif', 100);
?>
resize-class.php的类文件位于上面的链接中。请帮忙! 出现的警告是:
Warning: imagesx() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\mgme-cms\resize\resize_class.php on line 17
Warning: imagesy() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\mgme-cms\resize\resize_class.php on line 18
Warning: Division by zero in C:\xampp\htdocs\mgme-cms\resize\resize_class.php on line 106
Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in C:\xampp\htdocs\mgme-cms\resize\resize_class.php on line 59
Warning: imagecopyresampled() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\mgme-cms\resize\resize_class.php on line 60
Warning: imagegif() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\mgme-cms\resize\resize_class.php on line 206
Warning: imagedestroy() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\mgme-cms\resize\resize_class.php on line 229