1
我正在使用uploadify上傳圖片。有沒有什麼辦法可以限制用戶上傳圖片的寬度:670px height:200px。 這裏是我的uploadify.php代碼在uploadify中限制圖片上傳
<?php
require_once("includes/connection.php");
$targetFolder = '/workbench/sudeepc/photogallery/uploads' ;
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile = rtrim($targetPath,'/') . '/' . $_FILES['Filedata']['name'];
// Validate the file type
$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
$query="INSERT INTO `photo` (`id` , `path` , `uname`)
VALUES (
'','${targetFile}', 'testnn');";
mysql_query($query,$connection);
} else {
echo 'Invalid file type.';
}
}
?>
在此先感謝。