jQuery.AjaxFileUpload.js icon indicating copy to clipboard operation
jQuery.AjaxFileUpload.js copied to clipboard

reset INPUT file= field

Open VitoAsaro opened this issue 11 years ago • 2 comments

Jordan, Thanks for the help on the previous topic. I was able to get the work-around with the Submit-button parameter.

I have a small problem however: This function allows the user to never leave the page, therefor the form from which it is called has an INPUT file= field, and this field is not cleared the next time the form appears. I've tried everthing via javascript and jquery to reset the value of the "input file" field to an empty string, or otherwise reset it, but I can't seem to reset/clear the field without breaking the ability to call the ajaxfileupload function again.

Thanks again! -Vito

VitoAsaro avatar Mar 14 '14 00:03 VitoAsaro

Try remove()'ing it from the DOM, and creating (and re-initializing) an new input.

Browsers have security checks so you can't fiddle with the value of File type inputs.

~ Jordan

See what I'm into on AngelList https://angel.co/jordan-feldstein

On Thu, Mar 13, 2014 at 5:34 PM, VitoAsaro [email protected] wrote:

Jordan, Thanks for the help on the previous topic. I was able to get the work-around with the Submit-button parameter.

I have a small problem however: This function allows the user to never leave the page, therefor the form from which it is called has an INPUT file= field, and this field is not cleared the next time the form appears. I've tried everthing via javascript and jquery to reset the value of the "input file" field to an empty string, or otherwise reset it, but I can't seem to reset/clear the field without breaking the ability to call the ajaxfileupload function again.

Thanks again! -Vito

Reply to this email directly or view it on GitHubhttps://github.com/jfeldstein/jQuery.AjaxFileUpload.js/issues/38 .

jfeldstein avatar Mar 20 '14 23:03 jfeldstein

Here's a solution to this issue

I think this shouldn't be handled by the plugin because the input is not always inside a form

Putting the reset code inside the complete callback would solve the issue

https://www.gyrocode.com/articles/how-to-reset-file-input-with-javascript/

unlocomqx avatar Nov 12 '17 13:11 unlocomqx