如何捕獲上傳到我的web服務器的文件上的錯誤,該文件大於php upload_max_filesize?PHP文件上傳大於upload_max_filesize,錯誤
我的問題與so/large-file-upload-errors-with-php類似,雖然我的內存限制設置爲512M,所以問題所使用的分辨率對我沒有幫助。
我想上傳一個文件6.9MB,例如我的upload_max_filesize = 6M。我的腳本基本上只是停止執行,我不知道在哪裏或爲什麼。另外,我打開了錯誤報告。我
也應該注意到,文件< 6MB我可以用下面的代碼正確上傳和處理:
if(isset($_FILES['file']['name']) and !empty($_FILES['file']['name'])){
$info = pathinfo($_FILES['file']['name']);
$ext = $info['extension'];
//verify file is of allowed types
if(Mimetypes::isAllowed($ext)){
if(filesize($_FILES['file']['tmp_name']) <= AttachmentUploader::$maxFilesize){
$a = new AttachmentUploader(); //for file uploading
if($a->uploadFile($_FILES['file'], 'incident', $_POST['sys_id'])){
header("location: ".$links['status']."?item=incident&action=update&status=1&place=".urlencode($links['record']."id=".$_POST['sys_id']));
}else{
header("location: ".$links['status']."?item=incident&action=update&status=-1&place=".urlencode($links['record']."id=".$_POST['sys_id']));
}
}else{
$errors[] = 'The file you attempted to upload is too large. 0.5MB is the maximum allowed size for a file. If you are trying to upload an image, it may need to be scaled down.';
}
}else{
$errors[] = 'The file you attempted to upload is not allowed. Acceptable extensions: jpg, gif, bmp, png, xls, doc, docx, txt, pdf';
}
}else{
$errors[] = 'Please attach a file.';
}
我的php.ini設置:
;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;
max_execution_time = 7200 ; Maximum execution time of each script, in seconds
memory_limit = 512M ; Maximum amount of memory a script may consume (8MB)
;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;
; Whether to allow HTTP file uploads.
file_uploads = On
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
upload_tmp_dir = /tmp
; Maximum allowed size for uploaded files.
upload_max_filesize = 6M
請問你的Web服務器日誌的任何錯誤?你是否超過'max_input_time'? – Wrikken 2010-09-21 16:55:05
我無法理解我是在最大輸入時間,因爲我在千兆局域網上連接到服務器,並且一個大於6MB的文件幾乎是瞬間完成的。我會檢查它。 – Chris 2010-09-21 16:59:56