如何用Javascript中的默认目录打开文件浏览器? [英] How to open a file browser with default directory in Javascript?
问题描述
我想用JavaScript打开一个文件浏览器,并为此文件浏览器设置一个默认目录。
例如,我想将默认目录设置为C:\ My Documents。
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".
如何设置默认目录?
最好使用< input type =file/>
,其他控件也可以。
How to set a default directory?
It's better to use <input type="file"/>
, other controls are ok too.
推荐答案
这是不可能的,因为让网站代码在机器上设置任何值是一种安全风险。
This is impossible, as it is a security risk to let website code set any value on the machine.
此外,您永远无法确定该目录是否存在。
如果我在Mac上怎么办?我的东西在〜/ Pictures
中。如果我在 D:\
?上安装Windows?
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:\
?
这篇关于如何用Javascript中的默认目录打开文件浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!