How to open file browser with default directory in Javascript?

I want to open the file browser in JavaScript and set the default directory for this file browser. For example, I would like to set the default directory to "C: \ My Documents".

How to set the default directory? It’s better to use <input type="file"/> , other controls are fine too.

+4
source share
2 answers

This is not possible, as it is a security risk allowing the site code to set any value on the machine.

In addition, you can never be sure that a directory exists. What if I am on a Mac? My stuff is in ~/Pictures . What if I installed Windows on D:\ ?

+6
source

From http://www.pcreview.co.uk/threads/automatically-put-a-default-filename-in-input-type-file-value.2192852/

<input type="file" value="YourDefaultPathAndFilename.AndExtension">

0
source

Source: https://habr.com/ru/post/1489232/


All Articles