我知道这非常接近完成。我的目标是将用户上传的图像重新调整 0.5 倍。我已经实现了返回上传图像的宽度和高度,并将这些值减半。下面的代码:
//get image attributes
$target = "Images/";
$target = $target . basename($_FILES['myFile']['name']);
$thumbnailsize = 0.5;
//Get uploaded image width and height.
list($width, $height) = getimagesize($target);
//Half the current image in size.
$newWidth = $width * $thumbnailsize;
$newheight = $height * $thumbnailsize;
$new_target = imagecreatefromjpeg($target);
$image = imagecreate($newWidth, $newheight);
imagecopyresized($image, $new_target, 0, 0, 0, 0, $newWidth, $newheight, $width, $height);
$pic = $_FILES['myFile']['name'];
move_uploaded_file($_FILES['myFile']['tmp_name'], $target);
我想我现在的变量使用和 UPDATE SQL 语句出错了,见下文:
$tUser_SQLselect = "UPDATE User SET imageLocation='" . $pic . "' ";
$tUser_SQLselect .= "WHERE ID = '" . $userID . "' ";
任何建议将不胜感激,谢谢。