Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1154 How can I set the value of a fileupload form field?

You are here: irt.org | FAQ | JavaScript | Form | 3.3 | Q1154 [ previous next ]

Because of security implications (scripts setting the value, and then attempting to retrieve files of your computer) the value of the fileupload form field is read only. Therefore you cannot set, or reset the value.

In Netscape Navigator 2 the value is always empty, even after the user has selected a file for upload.

In Netscape Navigator 4 it is possible to set the value after asking for extra privileges:

<form name="myForm">
<input type="file" name="myFile">
</form>

<script language="JavaScript"><!--
if (document.layers && navigator.javaEnabled()) {
    netscape.security.PrivilegeManager.enablePrivilege('UniversalFileRead');

    document.myForm.myFile.value = "/secret/passwords";
}
//--></script>

©2018 Martin Webb