您好,我需要獲取已上傳圖片的高度和寬度。獲取圖片的高度和寬度PHP
這是我使用的PHP函數,但它不返回寬度和高度的任何東西..
你能幫幫我嗎?
list($width, $height, $type, $attr) = getimagesize($_FILES["Artwork"]);
$min_width = "1000";
$min_height = "1000";
if ((($_FILES["Artwork"]["type"] == "image/gif") || ($_FILES["Artwork"]["type"] == "image/jpeg") || ($_FILES["Artwork"]["type"] == "image/jpg")
|| ($_FILES["Artwork"]["type"] == "image/pjpeg")) && ($_FILES["Artwork"]["size"] < 20000000) && ($width > $min_width) && ($height > $min_height) && ($width == $height))
{
if ($_FILES["Artwork"]["error"] > 0)
{
//echo "Return Code: " . $_FILES["Artwork"]["error"] . "<br />";
}else{
move_uploaded_file($_FILES["Artwork"]["tmp_name"],
$path_image . $imageName);
header("Location: http://pitchmystuff.co.uk/m/digidist/tracks/".$idAlbum."");
}
}else{
//echo "invalid file";
echo '<script>
alert("There was an error uploading your coverart file. Please check the requirements and try again.'.$width.$height.'");
document.location ="http://pitchmystuff.co.uk/m/digidist/albums/";
</script>';
}
'getimagesize()'是票。你只是沒有使用正確的變量作爲參數。應該有這樣的錯誤消息:激活錯誤報告以查看它。 –
[獲取圖像高度和寬度作爲整數值?]可能重複(http://stackoverflow.com/questions/2179100/get-image-height-and-width-as-integer-values) –