我正在尝试上传图像,然后调整图像大小并保存。上载正常,并且调整大小也可以,但是调整大小的图像无法保存。如果我使用标题(“内容类型:图片/ jpeg”);然后它也会显示调整大小的图像。但调整大小后,图像将无法保存。 这是我的代码:
$filename = $_FILES['myfile']['name'][$count] ;
$filename = uploadfilename($filename);
$filename1=$iiid."blog".$filename;
$target_path = "../photo/";
$target_path = $target_path . repc($filename1);
move_uploaded_file($_FILES['myfile']['tmp_name'][$count], $target_path);
$dbfield = $count+1;
$sql="update product set img_".$dbfield." ='".rep($filename1)."' where id='".$iiid."'";
$result=mysql_query($sql);
$count++;
// header ("Content-type: image/jpeg");
// print_r(get_resource_type($uploadedImage));exit();
// $resizedImage = PIPHP_ImageResize($target_path,400,400);
$w = 100;
$h = 100;
list($width, $height) = @getimagesize($target_path);
$source = @ImageCreateFromJPEG($target_path);
$resized_img = @ImageCreateTrueColor($w, $h);
@ImageCopyResampled($resized_img, $source, 0, 0, 0, 0, $w, $h, $width, $height);
@ImageJPEG($resized_img);