![](/img/trans.png)
[英]I Want to Upload an image in database through php,the image is not uploading in database
[英]I want to resize and upload an image in PHP, but the image is not uploading
我想調整大小並在PHP中上傳圖片,但是該圖片未使用以下代碼上傳。 我要去哪里錯了?
public function category()
{
$picture = $_FILES ['image'] ['name'];
header('Content-type: image/JPG');
$myimage = resizeImage($picture, '190', '80');
$filename = $picture;
$newwidth = $_POST ['width'];
$newheight = $_POST ['height'];
list ($width, $height) = getimagesize($picture);
if ($width > $height && $newheight < $height) {
$newheight = $height / ($width / $newwidth);
} else if ($width < $height && $newwidth < $width) {
$newwidth = $width / ($height / $newheight);
} else {
$newwidth = $width;
$newheight = $height;
}
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
$result = move_uploaded_file($source, "images/" . $filename);
if ($result) {
$responseJSON = array("Status" => "True", "Message" => "image uploaded successfully");
$response = json_encode($responseJSON);
echo $response;
}
}
我認為
$source = imagecreatefromjpeg($filename);
應該
$truefile=$_FILES ['image'] ['tmp_name'];
$source = imagecreatefromjpeg($truefile);
嘗試發布您的答案
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.