读取 HTML 页面中本地文件夹中的文件名 [英] Read file names in a local folder in an HTML page

查看:61
本文介绍了读取 HTML 页面中本地文件夹中的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个 HTML 页面,我需要在其中显示特定本地文件夹中存在的文件的名称,例如 - C:UsersUser1Documentsfolder1 .我试图用 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:UsersUser1Documentsfolder1 . 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.

参考:JavaScript:读取文件夹中的文件

谁能帮助我实现这一目标?

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)小程序读取任意文件.然而,这需要用户批准一系列非常可怕的警告对话框——并且需要 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.

这篇关于读取 HTML 页面中本地文件夹中的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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