我想用 JavaScript 打开一个文件浏览器,并为这个文件浏览器设置一个默认目录。例如,我想将默认目录设置为“C:\My Documents”。
如何设置默认目录?最好用<input type="file"/>
,其他控件也可以。
我想用 JavaScript 打开一个文件浏览器,并为这个文件浏览器设置一个默认目录。例如,我想将默认目录设置为“C:\My Documents”。
如何设置默认目录?最好用<input type="file"/>
,其他控件也可以。
这是不可能的,因为让网站代码在机器上设置任何值都存在安全风险。
此外,您永远无法确定该目录是否存在。如果我在 Mac 上怎么办?我的东西在~/Pictures
。如果我安装了 Windows 会D:\
怎样?
<input type="file" value="YourDefaultPathAndFilename.AndExtension">