How can I catch an error in a file uploaded to my web server that is bigger than php upload_max_filesize?
My question is similar to so / large-file-upload-errors-with-php , although my memory limit is set to 512 M, so the resolution that will be used will not help me.
I am trying to upload a 6.9MB file, for example, and my upload_max_filesize = 6M. My script basically just stops executing, and I can't say where and why. In addition, I have included an error report.
It should also be noted that I can upload and process files <6MB correctly using the following code:
if(isset($_FILES['file']['name']) and !empty($_FILES['file']['name'])){
$info = pathinfo($_FILES['file']['name']);
$ext = $info['extension'];
if(Mimetypes::isAllowed($ext)){
if(filesize($_FILES['file']['tmp_name']) <= AttachmentUploader::$maxFilesize){
$a = new AttachmentUploader();
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.';
}
My php.ini settings:
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 = On
upload_tmp_dir = /tmp
upload_max_filesize = 6M
Chris