I am using dropzone extension for Yii framework to upload some files by registered users. Everything working well but some users for some files that they trying to upload it's return error = 3 which it's happens when the uploaded file was only partially uploaded.
$file_error = $_FILES['Project']['error']['file'];
if ($file_error != 0) {
mail('[email protected]', 'fileError',json_encode($_FILES['Project']));
}
i'am receiving a lot of emails from this function
JSON received
{"name":{"file":"3.jpg"},"type":{"file":""},"tmp_name":{"file":""},"error":{"file":3},"size":{"file":0}}
This error happened 1- if the user refresh the page while uploading. 2- if the user cancel the upload (there is no cancel option in my site). 3- if the internet connection lost while uploading.
I'm still looking for other cases.
PHP $_FILES The global predefined variable $_FILES is an associative array containing items uploaded via HTTP POST method. Uploading a file requires HTTP POST method form with enctype attribute set to multipart/form-data.
by default PHP will not handle file uploads larger than 2MB, if one requires PHP to handle larger files then one must set upload_max_filesize and post_max_size in your php. ini file to be larger than 2MB.
You may get an error message when you upload a file in the wrong format. Make sure you're using a supported file type. You can also try changing your codecs or editing software.
Error Messages Explained ¶ The error code can be found in the error segment of the file array that is created during the file upload by PHP. In other words, the error might be found in $_FILES['userfile']['error'] . Value: 0; There is no error, the file uploaded with success.
in my case, the "partially uploaded" problem happened when uploading medium/large files using a slow internet connection.
The solution that works for me was set some Apache configurations in httpd.conf file:
TimeOut 300
KeepAliveTimeout 10
RequestReadTimeout handshake=0 header=20-1200,MinRate=200 body=20,MinRate=200
I hope it help.
As php documentation says, this error is
UPLOAD_ERR_PARTIAL is given when the mime boundary is not found after the file data.
A possibly cause for this is that the upload was cancelled by the user (pressed ESC, etc).
Also there are some more variants to check:
Permissions are wrong (i doubt, cause it will break all users).
Not enough free space on server.
This error occures when uploading from iOS.
This error can occure when uploading folder (due to browser limitations). On Mac OSX it occures 100%.
So this is possible errors to check. Hope this will help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With