• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File Upload in HTML and Javascript

 
Arvind Prabhu
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an HTML page that allows users to upload files via the <input type="file" /> field. I have some Javascript in which I want to change the value of this file input field.
I tried ...
form.filefield.value = "new value";
however, it does not work ... because the value property of the file input field is READ-ONLY. Does anyone know of any way to change the value of this field in Javascript?
Thanks,
-Arvind
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nope....
 
Arvind Prabhu
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, what I was trying to do was to clear the value such that no file is uploaded when the user clicks on a checkbox.
I found another way to prevent the file upload - and that is to disable the file input field.
A follow up question:
How can I perform error checks on the filename specified by the user. I want to see if the file exists on the user's file system and present an error dialog if there are problems.
Thanks,
-Arvind
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When a form element is disabled, the form acts like it is not there when the form is being submmited. You can not chnage the value of the drop down for security reasons.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic