I want to open a file browser in JavaScript and set a default directory to this file browser. For example, I will like to set the default directory to "C:\My Documents".
How to set a default directory?
It's better to use <input type="file"/>
, other controls are ok too.
I want to open a file browser in JavaScript and set a default directory to this file browser. For example, I will like to set the default directory to "C:\My Documents".
How to set a default directory?
It's better to use <input type="file"/>
, other controls are ok too.
2 Answers
Reset to default 21This is impossible, as it is a security risk to let website code set any value on the machine.
Also, you can never be sure that directory exists.
What if I'm on a Mac? My stuff are in ~/Pictures
. What if I installed Windows on D:\
?
From http://www.pcreview.co.uk/threads/automatically-put-a-default-filename-in-input-type-file-value.2192852/
<input type="file" value="YourDefaultPathAndFilename.AndExtension">
html5
likeimages
,documents
ormovies
as default. But even if it is now possible, defining a whole path likeC:\My Documents
(i hope it is not possible) would not make much sens, because the path could change from system to system. – t.niese Commented Jul 2, 2013 at 8:20