Reputation:
So I have a working file upload system on my site.... and it basically works every single time anyone uses it. There have been a few cases where users have submitted data and the page has basically returned a PHP UPLOAD_ERR_NO_FILE, but I've only seen this occur via the Chrome browser (recent versions being 94.0.4606.81 & 95.0.4638.54). Every time I try in Chrome myself it works fine, and these users never really communicate there is a problem and don't come back, I just see it in the logs that it's happened. I'm just wondering whether anyone knows of any browser extensions or anything which may be interfering in this from Chrome's point of view? i.e. wiping the files before they're sent?
I don't really use Chrome so I'm not that aware of how it functions, but I'm assuming it doesn't really handle things that different to the other browsers in terms of HTTP headers and data??
I just find it bizarre that someone would try to upload a file, fill out all the other input fields, press submit but not actually upload a file. For the record:
Upvotes: 1
Views: 657
Reputation: 198001
UPLOAD_ERR_NO_FILE
Value: 4; No file was uploaded. (ref)
Is that there was no file.
Like this form submitted without selecting a file:
<form method="post" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit"> <input type="reset">
</form>
As it's client side, there can be client side scripts that remove the file when the form is submitted. For example:
document.forms[0].file.value = ""
Magic? Bizarre? Likely not, your form handling should deal with it. E.g. display the form again, mark the inputs where data was missing / wrong, give an accessible error message and fill all form-fields with the submitted value so that the user can fix any errors easily and must not completely re-fill the form nor clears the whole form with the reset button.
You can also mirror the error handling on the client side with client-side scripts so that the feedback for the user is even faster and you spare a round-trip to the server for common user-input-errors.
Upvotes: 0