Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting value of file input programmatically [duplicate]

I have already read up on this here, and know that it is impossible due to security restrictions, however I have a few more specific questions about this.

  1. What about for a machine that is not connected to the internet? Are there any chrome settings that I could set in order to allow this?
  2. What would happen if I were to change the input type to text and then add the file path and proceed to submit the form? will it work for selecting a file to run? I cannot test this because I am working with a router UI through HTML and while it may seem like it is working when I hit submit I can't tell if it is actually changing anything
like image 620
Adjit Avatar asked Oct 27 '25 09:10

Adjit


1 Answers

<input type="file"> doesn't allow you to set the value programmatically but it must be the user who locates the file to upload. Thus, you can't turn your input into a type="text", set a path and turn the so-called input into type="file" again and hold the value.

What would happen if I were to change the input type to text and then add the file path and proceed to submit the form? will it work for selecting a file to run?

It would send the file path instead of the file.

like image 173
Matías Fidemraizer Avatar answered Oct 28 '25 23:10

Matías Fidemraizer