如何用Javascript中的默认目录打开文件浏览器? [英] How to open a file browser with default directory in Javascript?

查看:129
本文介绍了如何用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆