• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

clearing file input

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to clear file input (file upload)?

I am trying this:

document.getElementById("file_browse").value = "";

But it doesn't seem to work. How to achieve this?

TIA.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can not change the value of a file for security reasons. Try .reset();

Eric
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Eric Pascarello:
You can not change the value of a file for security reasons. Try .reset();

Eric


Getting 'object doesn't support this property' error. :roll:
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about this:



Worked on Firefox and IE, but not sure whether this is a clean approach of doing this.
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jaikiran Pai:
How about this:



Worked on Firefox and IE, but not sure whether this is a clean approach of doing this.


Nice thinking...
Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic