0
我有這部分代碼,我嘗試了幾個像「或」和「其他」的東西,但它不能正常工作。所以atm它適用於.jpg文件格式,並且可以很好地上傳它,當我嘗試添加帶有1-2mb限制的.gif文件時,它並沒有上傳它。你能幫我嗎?Php圖像類型上傳問題gif png
if (($ext == "jpg") && ($_FILES["uploaded_file"]["type"] == "image/jpeg") && ($_FILES["uploaded_file"]["size"] < 350000))
我用
if (($ext == "gif") && ($_FILES["uploaded_file"]["type"] == "image/gif") && ($_FILES["uploaded_file"]["size"] < 2000000))
於GIF和
if (($ext == "png") && ($_FILES["uploaded_file"]["type"] == "image/png") && ($_FILES["uploaded_file"]["size"] < 1000000))
,但它沒有工作,所以如果有人可以幫我請=)
全部分該代碼只是jpeg是:
if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) {
//Check if the file is JPEG image and it's size is less than 350Kb
$filename = basename($_FILES['uploaded_file']['name']);
$ext = substr($filename, strrpos($filename, '.') + 1);
if (($ext == "jpg") && ($_FILES["uploaded_file"]["type"] == "image/jpeg") && ($_FILES["uploaded_file"]["size"] < 350000)){
//Determine the path to which we want to save this file
$newname = dirname(__FILE__).'/upimg/'.$filename;
//Check if the file with the same name is already exists on the server
if (!file_exists($newname)) {
//Attempt to move the uploaded file to it's new place
if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))) {
謝謝,我完全忘了! – Sandra
@Sandra我的榮幸:) –