4

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
Community
  • 1
  • 1
Adjit
  • 10,134
  • 12
  • 53
  • 98
  • 2
    Setting a text input to a file path is not going to submit a file. – epascarello Nov 17 '15 at 22:18
  • @epascarello ok, so that at least answers the second part of my question. I also tried changing the type to text, and then back to file again, but it just gets rid of the input value – Adjit Nov 17 '15 at 22:20
  • @epascarello what if I create a new file input element, is it possible to set like a default value for it or something? – Adjit Nov 17 '15 at 22:22
  • Unless there is some browser config you can set, I doubt it. Even the html5 api requires user to select. – epascarello Nov 17 '15 at 22:30

1 Answers1

2

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

Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206