# Change a html file field value via js?

**URL:** https://forum.kirupa.com/t/change-a-html-file-field-value-via-js/161584
**Category:** web dev
**Created:** [September 5, 2005, 12:33pm UTC](https://forum.kirupa.com/t/change-a-html-file-field-value-via-js/161584 "2005-09-05T12:33:42Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![andr\_in](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/andr_in/32/37_2.png) [@andr\_in](https://forum.kirupa.com/u/andr_in)
#### Post date: [September 5, 2005, 12:33pm UTC](https://forum.kirupa.com/t/change-a-html-file-field-value-via-js/161584/1 "2005-09-05T12:33:42Z")

</div>

Suppose I have

_\<input type=“file” name=“foo” id=“foo” /\>_

How do I change its value via javascript?  
I can read the value very well by just going

_document.formname.foo.value;_

but it seems to be read-only or something cuz trying to assign a value to it results in something like (in the js console)  
_Error: uncaught exception: [Exception… “Security error” code: “1000” nsresult: “0x805303e8 (NS\_ERROR\_DOM\_SECURITY\_ERR)” location: “\<filename\> Line: #”]_  
😏
