1

I am working on a web page which has a file uploader. After I click the button 'Discard changes', I want the contents of the file uploader to be purged. I was thinking to do this by refreshing the fileuploader using jQuery.

How can this be done in jQuery please? Thanks :)

Edit

The file uploader I am using makes use of a jQuery library so that it can upload several photos at once. As a result, changing its value to "" does not work in this case.

That's why I'd like to reload it all together using jQuery.

This is the plugin I am using:

http://www.dotnetcurry.com/ShowArticle.aspx?ID=317

3
  • This is the plugin I am using: dotnetcurry.com/ShowArticle.aspx?ID=317 Commented Mar 19, 2012 at 13:07
  • Unfortunately that plugin is not flexible at all. Just emptying out the div contents doesn't seem to work. Commented Mar 19, 2012 at 13:31
  • Thanks Interstellar_Coder :) I will try to find a better plug-in. Commented Mar 19, 2012 at 14:43

1 Answer 1

1

Give the File input an id or a class, let's say this id is "img" and then use

$('input#img').val("");
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for the response. I should have mentioned in my question that I am using a jQuery plugin so that the FileUploader can upload several images at once.
That's why I was thinking to refresh the fileuploader all together.
Ok, the thing is, javascript can only do as much as change the value displayed in the uploader, it is not authorized to delete the file mounted in the uploader since javascript cannot handle files, you could put the form in a separate file and use jQuery's load() function like this: $('div#foo').load('link/to/file/containing/form.php');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.