0

So I have a form with a filetype input, and found a bug where if the user chooses a file for the input, then deletes/moves the file from their filesystem (the filetype input still having the original file path they chose as the value) and then submits the form, it gives a Chrome "missing_file_err" which makes sense since the path to the file they provided no longer is accurate.

Is there a way to avoid this? Is there perhaps some sort of file upload widget I can use that keeps a copy of the file when they select it even if they move or delete it before submitting?

Trippze
  • 17
  • 5
  • Its not a bug, its a (security) feature. You might want to look into async file uploads and start uploading the file immediatly when the user selects it. Otherwise there is no workaound for this, because you dont have control over the users file system. https://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously/8758614#8758614 – rx2347 Mar 06 '20 at 15:07

1 Answers1

0

It's going to be very rare that a user enters information into a form, deletes a file, and then submits the form.

One way of avoiding this would be to automatically submit the form once the file is selected.

$('#fileToUpload').change(function() {
    $('#submit').click();
});