Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open a file browser with default directory in Javascript?

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.

like image 891
ldlchina Avatar asked Jul 02 '13 08:07

ldlchina


1 Answers

This 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:\?

like image 51
casraf Avatar answered Sep 28 '22 08:09

casraf