faqts : Computers : Programming : Languages : JavaScript : Forms : File Upload

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

225 of 298 people (76%) answered Yes
Recently 2 of 10 people (20%) answered Yes

Entry

Can I (pre)set the value of a INPUT TYPE="file" element?

May 29th, 2001 11:55
Martin Honnen,


With NN4 and NN6 you can (pre)set the value of an
  <INPUT TYPE="file">
element, but only with trusted script:
  <FORM NAME="aForm"
        METHOD="post"
        ENCTYPE="multipart/form-data"
        ACTION="yourUploadHandler"
  >
  <INPUT TYPE="file" NAME="aFile">
  <INPUT TYPE="submit" VALUE="send us your registry">
  </FORM>
  <SCRIPT>
  if (window.netscape) {
    netscape.security.PrivilegeManager.enablePrivilege
('UniversalFileRead');
  }
  document.aForm.aFile.value = 'C:\\WINDOWS\\System.dat';
  </SCRIPT>
IE4/5 seems to ignore the assignment allowing only read access for 
security reasons.