$_FILES['file']['error']值
UPLOAD_ERR_OK: 0 //正常,上傳成功
UPLOAD_ERR_INI_SIZE: 1 //上傳文件大小超過服務器允許上傳的最大值,php.ini中設置upload_max_filesize選項限制的值
UPLOAD_ERR_FORM_SIZE: 2 //上傳文件大小超過HTML表單中隱藏域MAX_FILE_SIZE選項指定的值
UPLOAD_ERR_NO_TMP_DIR: 6 //沒有找不到臨時文件夾
UPLOAD_ERR_CANT_WRITE: 7 //文件寫入失敗
UPLOAD_ERR_EXTENSION: 8 //php文件上傳擴展沒有打開
UPLOAD_ERR_PARTIAL: 3 //文件只有部分被上傳
復制代碼 代碼如下:
switch($_FILES[$field]['error']) {
case 1:
// 文件大小超出了服務器的空間大小
$this->setError("The file is too large (server).");
break;
case 2:
// 要上傳的文件大小超出浏覽器限制
$this->setError("The file is too large (form).");
break;
case 3:
// 文件僅部分被上傳
$this->setError("The file was only partially uploaded.");
break;
case 4:
// 沒有找到要上傳的文件
$this->setError("No file was uploaded.");
break;
case 5:
// 服務器臨時文件夾丟失
$this->setError("The servers temporary folder is missing.");
break;
case 6:
// 文件寫入到臨時文件夾出錯
$this->setError("Failed to write to the temporary folder.");
break;
}