您好我正在尋找與我的主圖像一起創建縮略圖。我希望它被存儲在不同於原始文件夾的文件夾中,最大高度爲400像素。我搜索了一下,但似乎太複雜了。我在尋找相當簡單的東西。我是新來的文件上傳的東西。以下是我目前擁有的代碼。在不同文件夾中的PHP商店中創建縮略圖
// Configuration
$allowed_filetypes = array('.jpg', '.JPG', '.bmp', '.png', '.gif');
$max_filesize = 100000000;
$upload_path = 'artimages/';
$filename = $_FILES['userfile']['name'];
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);
// Random Number
$randomnumber = rand(1, 1000000);
$filename = $randomnumber.$filename;
// File Size
if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
die('The file you attempted to upload is too large.');
// File Type
if(!in_array($ext,$allowed_filetypes))
die('The file you attempted to upload is not allowed.');
// Check CHMOD 777
if(!is_writable($upload_path))
die('Fail');
// Upload File
if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename))
echo 'Success';
else
echo 'Fail';
它的工作表示感謝。如果原始圖像小於所選的拇指寬度,會發生什麼情況? – Munnaz 2014-10-29 04:40:54