jfeldstein / jQuery.AjaxFileUpload.js

jQuery plugin to magically make file inputs upload via ajax
408 stars 246 forks source link

reset INPUT file= field #38

Open VitoAsaro opened 10 years ago

VitoAsaro commented 10 years ago

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

jfeldstein commented 10 years ago

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 notifications@github.com 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 .

unlocomqx commented 7 years ago

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/