在HTML页面的本地文件夹中读取文件名
我正在创建一个HTML页面,我需要显示特定本地文件夹中存在的文件的名称,例如 - C:\ Users \User1\Documents\folder1。我试图用java脚本编写代码,但还没有成功。大多数问题线程都提到要使用ActiveXObject,但它本身不适用于我。
I am creating a HTML page where I need to display the names of the files present in the specific local folder, example - C:\Users\User1\Documents\folder1 . I tried to write the code in java script but have not succeeded yet. Most of the question threads mention about "ActiveXObject" to be used but that itself does not work for me.
Reference: JavaScript: Read files in folder
任何人都可以帮助我实现这个目标吗?
Can anyone help me in achieving this?
一般来说,你不能那样做。网页无权访问本地文件系统。
In general, you can't do that. Web pages do not have access to the local filesystem.
Chrome可以访问使用文件输入字段选择的目录的内容但是,其他浏览器(例如Internet Explorer和Firefox)此时尚未实现此功能,目前也没有任何方式可以访问已被不是由用户选择的。
Chrome can access the contents of a directory that is selected using a file input field. However, other browsers, such as Internet Explorer and Firefox, have not implemented this feature at this time, nor is there currently any way to access a directory that was not selected by the user.
理论上,可以使用签名的Java(不是Javascript)applet读取任意文件。但是,这要求用户批准一系列非常可怕的警告对话框 - 并且需要Java! - 所以这真的不是一个可行的解决方案。
In theory, it is possible to read arbitrary files using a signed Java (not Javascript) applet. However, this requires the user to approve a series of extremely scary warning dialogs — and requires Java! — so it's really not a viable solution.