问题描述
我正在开发桌面应用程序项目。我正在使用使用visual c ++控件。
我在QWebView中加载一个html文件,
I am working on project for desktop application. I am using Qt controls with visual c++.I am loading an html file in the QWebView as,
m_pWebView->load(QUrl("../../../demo/index_Splash_Screen.html"));
现在,我想要的是,比方说,我有一些 .zip
我所在位置的文件c:\ demo,我想要该目录中存在的文件的列表(或文件名数组)。
Now, what i want is, say, I have some .zip
files in my location "c:\demo", I want list (or array of file names) of the files present in that directory.
我如何通过javascript完成此操作?
How can i do this through javascript ?
PS:我经历了这个,但它不符合我的要求。我没有使用过html,javascript和jquery。请帮助我。
PS: I went through this link, but it didnt match my requirement. I have not worked with of html, javascript and jquery. Please help me.
推荐答案
由于安全问题,我担心你无法使用javascript访问本地文件或目录。
I'm afraid you cannot access local files or directories using javascript due to security issues.
编辑:我没有想过文件api所以想了一下这可能不是真的,但如果没有一些用户输入来给予许可,这仍然无法完成。
I hadn't thought about the file api so thought for a moment this might not be true, but without some user input to give permission, this still cannot be done.
得到了PhilNicholas的好评:
This question has a good response from PhilNicholas:
这将是一个巨大的安全风险,浏览器脚本只需
在没有任何用户
交互的情况下,任意打开并读取路径中的任何文件。没有任何浏览器制造商允许对整个文件系统进行无限制的访问
。
It would be a huge security risk of browser scripts could just arbitrarily open and read any file from a path without any user interaction. No browser manufacturer would allow unfettered access to the entire file system like that.
考虑一下,如果它是所有都在本地运行,您可以使用ajax查询可能返回您请求的目录的服务器端脚本。
Thinking about it however, if it is all being run locally, you could use ajax to query a server side script that could return the directory you request.
这篇关于如何使用javascript获取文件夹中的文件列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!