2011-04-05 100 views
0
if (($ext=="zip") 
&& ($_FILES["file"]["size"] < 2000000)) 
    { 
    if ($_FILES["file"]["error"] > 0) 
    { 
    echo "Error: " . $_FILES["file"]["error"] . "<br />"; 
    } 
    else 
    { 
    $newname = 'forms/'.$filename; 
    move_uploaded_file($_FILES['file']['tmp_name'],$newname); 
     mysqli_select_db($connect,"forms"); 
    $s = "update loc set loc='$newname' where sessionusername = '$u' AND name = '$name'"; 
    $q = mysqli_query($connect,$s); 

    if($q) 
    { 
    header("Location:change.php"); 
    exit(); 
    } 
    else 
    { 
    echo "Oops, something went haywire. Please try again"; 
    } 

    } 
    } 
else 
    { 
    echo "Invalid file. Please try again."; 
    } 
    } 

當我上傳的文件,我得到的錯誤:1個幫助這個文件上傳腳本

更新 - 代碼在FF.NOT在Chrome中。

+2

是頁面只是輸出'1'?你嘗試過調試還是至少把'echo()'和找出程序的路徑?可能有助於 – JohnP 2011-04-05 12:04:40

+0

我喜歡「哎呀,事情失控了,請重試」 :) – 2011-04-05 12:11:08

+0

@lawrence公頃ha..thanks。 – sarthak 2011-04-05 12:32:06

回答

2

UPLOAD_ERR_OK

Value: 0; There is no error, the file uploaded with success. 

UPLOAD_ERR_INI_SIZE

Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini. 

UPLOAD_ERR_FORM_SIZE

Value: 2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form. 

UPLOAD_ERR_PARTIAL

Value: 3; The uploaded file was only partially uploaded. 

UPLOAD_ERR_NO_FILE

Value: 4; No file was uploaded. 

UPLOAD_ERR_NO_TMP_DIR

Value: 6; Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3. 

UPLOAD_ERR_CANT_WRITE

Value: 7; Failed to write file to disk. Introduced in PHP 5.1.0. 

UPLOAD_ERR_EXTENSION

Value: 8; A PHP extension stopped the file upload. PHP does not provide a way to ascertain which extension caused the file upload to stop; examining the list of loaded extensions with phpinfo() may help. Introduced in PHP 5.2.0. 
+0

這是有幫助的 – Drewdin 2011-04-05 13:09:59

1

值:1;上傳的文件超出了php.ini中的upload_max_filesize指令。