keep getting upload php $_FILES error = 3 (partially uploaded)

我与影子孤独终老i 提交于 2019-12-31 00:45:23

问题


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('myemail@gmail.com', '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}}

how can i debug this error and know the cases that make this error happened ?

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.


回答1:


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.




回答2:


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:

  1. Permissions are wrong (i doubt, cause it will break all users).

  2. Not enough free space on server.

  3. This error occures when uploading from iOS.

  4. 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.



来源:https://stackoverflow.com/questions/25475805/keep-getting-upload-php-files-error-3-partially-uploaded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!