控制< input type =" file"&gt ;?的工作目录 [英] control the working directory for <input type="file">?

查看:107
本文介绍了控制< input type =" file"&gt ;?的工作目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全文:
我正在为我的公司开展一个项目,该项目要求我们每个地点的用户上传由第三方软件生成的报告。此软件生成的所有报告始终位于同一目录中。
我们的一些计算机知识较少的员工,根据过去(和持续)的经验来判断同样困难的任务:将发票下载/保存到供应商网站的特定目录中,将无法找到要从中上传的正确目录。

Full story: I am working on a project for my company that requires users at each of our locations to upload reports generated by a third party software. All reports generated by this software are always placed in the same directory. Some of our less computer-literate associates, judging by past(and ongoing) experience with a similarly difficult task: downloading/Saving invoices to a particular directory off a suppliers website, will have trouble finding the correct directory to upload from.

每个位置的计算机都运行Windows Server 2003,目前有IE6

The computers at each location are running Windows Server 2003 and currently have IE6

我们想增加默认情况下,通过将文件输入设置为指向正确的目录,易用性和合规性。

We would like to increase the ease of use, and compliance by setting the file inputs to point to the correct directory by default.

我最初希望能够直接在输入值中设置文件,但这在大多数浏览器中都是禁用的原因。
是否可以通过javascript或仅在HTML本身中控制用户按下浏览按钮时打开的目录?

I initially hoped to be able to set the files directly in the input values, but this is for good reasons disabled in most browers. Is it possible through javascript, or just in the HTML itself to control the directory that opens when the user presses the browse button?

如果没有,还有什么其他的关于如何完成它的建议?甚至可以像在桌面上成功设置快捷方式一样简单,这将迫使浏览器使用所需的工作目录。 (IE显然忽略了快捷方式的'start in'参数)

If not, what other suggestions on how to accomplish it? Even something as simple as a way to successfully set a shortcut on the desktop that will force the browser to use the required working directory. (IE apparently ignores the 'start in' parameter of shortcuts)

推荐答案

您无法使用JavaScript控制文件输入的内容安全原因。否则,您可以创建一个带有文件输入字段的隐藏表单,将其设置为路径,然后使用JavaScript提交表单,以便在用户不知情的情况下将文件上传到您的服务器。

You cannot control the contents of a file input using JavaScript for security reasons. Otherwise, you could create a hidden form with a file input field, set it to a path, and submit the form with JavaScript in order to upload the file to your server without the user knowledge.

不幸的是,我不知道如何设置文件选择器的默认路径。如果有的话,我确定它将是浏览器特定的,只能通过在客户端设置一些选项来使用,而不是通过HTML或JavaScript。

Unfortunately, I'm not aware of a way to set the default path for the file selector. If there is one, I'm sure it will be browser-specific and can only be used by setting some option in the client side, not through HTML or JavaScript.

这篇关于控制< input type =" file"&gt ;?的工作目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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