Search code examples
htmlformsfile-io

Pre-Populate HTML form file input


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?


Solution

  • 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.