Change a html file field value via js?

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: #”]
:smirk: