aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes File Upload in HTML and Javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "File Upload in HTML and Javascript" Watch "File Upload in HTML and Javascript" New topic
Author

File Upload in HTML and Javascript

Arvind Prabhu
Greenhorn

Joined: Aug 09, 2001
Posts: 18
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
nope....
Arvind Prabhu
Greenhorn

Joined: Aug 09, 2001
Posts: 18
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File Upload in HTML and Javascript