26

I have a VBScript that goes over an HTML form, fills it with fixed values and then submit it. It works fine so far, but now i need to set the location of a file that is going to be uploaded within the form data.

I believed if I set the location on the value it was going to work, but it doesn't.

 <input type='file' name="file_field" value='file_location'/>

Also, I found this while researching. It says...

input type=file Value: Sets or retrieves the displayed value for the control object. This value is returned to the server when the control object is submitted.

Is there a way (by code) to fill that input, even with jQuery?

Luigi Siri
  • 2,068
  • 2
  • 19
  • 27
  • 4
    That would be a bit of a security issue if you could change/prepopulate a user's file input fields. So no, you cannot do this. – antony May 03 '13 at 18:50

1 Answers1

50

No. This is not possible.

Browsers block against setting the value attribute on input of file type for security reasons so that you can't upload a file without the user's selected any file himself.

Igor Popov
  • 924
  • 8
  • 14
  • As for sure you can add only preview close around of this input with already uploaded file. This one is useful for image uploads. – Igor Popov May 17 '13 at 09:49