1
我知道這是非常接近完成。 我的目標是將用戶上傳的圖像重新放大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);
我想我現在跟我的變量使用和更新SQL語句去錯了,見下圖:
$tUser_SQLselect = "UPDATE User SET imageLocation='" . $pic . "' ";
$tUser_SQLselect .= "WHERE ID = '" . $userID . "' ";
任何建議將讚賞,感謝。