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?
By typing it in. By giving the input tag a value attribute with whatever text you want pre-populated.
The only way to set the value of a file input is by the user to select a file. This is done for security reasons. Otherwise you would be able to create a JavaScript that automatically uploads a specific file from the client's computer.
Create The HTML Form Some rules to follow for the HTML form above: Make sure that the form uses method="post" The form also needs the following attribute: enctype="multipart/form-data". It specifies which content-type to use when submitting the form.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With