Why might a file only be partially uploaded?

2019-01-18 18:06发布

Why might a file only be partially uploaded?

I am improving error-handling in my PHP file upload script and am trying to figure out how to handle UPLOAD_ERR_PARTIAL properly.

Should I prompt the user to try uploading the file again, or should I inform them that there is a more severe problem which is preventing them from uploading a possibly legitimate file?

6条回答
Melony?
2楼-- · 2019-01-18 18:42

Well, the file upload could be interrupted by:

Out of space in destination

Connection interruption

Damage file

Wrong name

Wrong extension

etc...

The best you can do is to verify and protect the upload process with does verifications before actually send the file to the server...

The first time I've made a file upload script, I used 1 line of code, now, the same script seems like a web page ;)

EDITED (example for controlling extension and file size):

if ((

($file_up["type"] == "image/gif") ||

($file_up["type"] == "image/jpeg") ||

($file_up["type"] == "image/jpg") ||

($file_up["type"] == "image/pjpeg") ||

($file_up["type"] == "image/bmp") ||

($file_up["type"] == "image/tiff") ||

($file_up["type"] == "image/png")) &&

($file_up["size"] < 1050000))

{

    code if all ok...


}
查看更多
该账号已被封号
3楼-- · 2019-01-18 18:52

Why might a file only be partially uploaded?

This is usually caused by the user canceling the upload.

Should I prompt the user to try uploading the file again, or should I inform them that there is a more severe problem which is preventing them from uploading a possibly legitimate file?

You should prompt them to try again and if problems continue to contact the site owners, including as much detail as possible.

查看更多
欢心
4楼-- · 2019-01-18 18:58

I have a same problem and was related with package libapache2-mod-php5filter , I remove the p and problem end. I hope someone can help.

查看更多
Lonely孤独者°
5楼-- · 2019-01-18 19:00

UPLOAD_ERR_PARTIAL is given when the mime boundary is not found after the file data. A possible cause for this is that the upload was cancelled by the user (pressed ESC, etc).

I think it's enough to inform the user that the file is only partially uploaded and a retry will fix the problem.

查看更多
我只想做你的唯一
6楼-- · 2019-01-18 19:01

This may help some people, but I had the same problem. My solution was to uninstall libapache2-mod-php5filter and replace it with the classical libapache2-mod-php5

查看更多
一夜七次
7楼-- · 2019-01-18 19:02

This is an old post, but I had a random problem of UPLOAD_ERR_PARTIAL, and post my solution.

The problem is that after 2/3 upload I obtained an error of UPLOAD_ERR_PARTIAL, without any interruption by the client.

My problem was related to the Keep-Alive server.

I solved it by inserting at the end of the PHP script for uploading

header ("Connection: close");

that forces the closure of the connection. This has solved my problem.

I hope someone can help.

Thank to this LINK

查看更多
登录 后发表回答