Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

File Upload in HTML and Javascript

 
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
 
author
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
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.
 
I've read about this kind of thing at the checkout counter. That's where I met this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic