Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Web Technology by (20.3k points)

Note:

The answers & comments below reflect the state of legacy browsers in 2009. Now you can actually set the value of the file input element dynamically/programmatically using JavaScript and a dataTransfer or FileList object in 2017.

See the answer in this question for details as well as a demo:

How to set file input value programatically (i.e.: when drag-dropping files)?

How can I set the value of this?

<input type="file" />

1 Answer

0 votes
by (40.7k points)

You can't do it. There is only a way to set the value of a file input is by the user to select a file.

This can also be done for security reasons. Otherwise, you will not be able to create the Javascript that automatically uploads a specific file from the clients computer.

Browse Categories

...