在javascript中查找本地文件或目录的路径 [英] Find the path of a local file or directory in javascript
问题描述
我们正在构建一个Web应用程序来帮助人们组织本地文件;它在HTML5 / JS中有一个文本输入字段。
We are building a web application to help people organize their local files; it has a text input field in HTML5/JS.
理想的功能:用户点击文本框,它可以让他们选择一个文件或本地驱动器上的文件夹,它将所述文件或文件夹的路径传递给我们的服务器。
Ideal functionality: user clicks on the text box and it lets them select a file or folder on their local drive, which passes the path of said file or folder to our server.
是否有JS API或HTML5方法来查找本地文件的路径和文件夹?
Is there a JS API or HTML5 method to find a path to a local file and folder?
推荐答案
由于浏览器安全性,您无法从FILE输入获取文件位置。出于同样的原因,您会注意到FILE输入在回发后总是被重置为空白。这是因为浏览器不会将文件路径作为安全措施保留或公开。
Due to browser security, you cannot get the file location from a FILE input. For that same reason, you will notice that FILE inputs always get reset to blank after a postback. This is because the browser will not persist or expose the file path as a security measure.
这篇关于在javascript中查找本地文件或目录的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!