Why might a file only be partially uploaded?
Solution 1
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.
Solution 2
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.
Solution 3
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
Solution 4
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... }
Solution 5
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
Related videos on Youtube
Mike Moore
Updated on July 27, 2020Comments
-
Mike Moore almost 4 years
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?
-
Zuul almost 14 yearshumm... yes, just imagine that your input should only be working with pictures and the user tries to upload a document, if it's supposed to be only pictures, you should deny any other file extensions (view my answer under the edit comment...
-
webbiedave almost 14 yearsThe question is how would a file name/extension cause a UPLOAD_ERR_PARTIAL?
-
Zuul almost 14 yearswell, it doesn't... the file extension was just a warning about possible errors that you might encounter... :) Specifically to UPLOAD_ERR_PARTIAL, what Halfdan said seems to be the only reason... so, just inform the user that the process was interrupted, and should try again!
-
tmsppc over 12 years+1 for clarifying "when the mime boundary is not found after the file data"
-
Treemonkey over 10 yearsWorked for me! I spent hours thinking my script was failing / flakey seems that it was the server.
-
Alex Ball over 10 years@Treemonkey happy to be useful ;-)
-
Meetai.com over 10 yearsDuplicated here: stackoverflow.com/questions/12425394/…
-
Ingwie Phoenix about 9 years@Seb Totally +1'd that one as well. Was running into a similar issue and that little side-note got me to the source. :)
-
tonix about 8 yearsHow should we handle this case on the client side with JS and on the server side with PHP? I mean, if the user starts an upload of a file and then clicks on a cancel button on the page while the file is still being uploaded, I can call
.abort()
how will PHP receive the information that the user canceled the upload? -
karllindmark about 8 yearsIn my case, I forgot the leading
--
on the last (in this case following) boundary. Lesson learned :-) -
Box Box Box Box over 7 years@yellowantphil looks like a borderline answer to me
-
globalSchmidt almost 6 years@halfdan - I'm not understanding why a mime boundary would be missing. Doesn't PHP handle the boundaries? Alternatively, when a program saves a file (a PDF or pptx in my case), aren't the beginning and end of the file set by the program used?
-
georaldc about 5 yearsI see this answer given out a lot but it would be great if someone could explain why forcing keepalive to be disabled would work.
-
Andrew Koster almost 2 years"contact the site owners"???