从chrome中的java脚本访问本地文件 [英] Accessing local file from java-script in chrome

查看:162
本文介绍了从chrome中的java脚本访问本地文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在asp .net上有一个网站。

我正在访问本地文件。

使用以下代码:



hi all,
I have a website in asp .net.
In that i am accessing local files.
by using following code:

var shellActiveXObject = new ActiveXObject("Scripting.FileSystemObject");
alert(shellActiveXObject.FileExists('C:/temp.txt'))







当文件存在时它会显示警报。

运行正常在IE中但不在Chrome中。

Becoz ActiveX在chrome中不起作用。

i获得了访问chrome中本地文件的链接。

< a href =http://wizard.ae.krakow.pl/~jb/localio.html> http://wizard.ae.krakow.pl/~jb/localio.html [ ^ ]



但他们已经给出了我不想要的打开对话框的输入文件控制。



非常感谢。

上帝保佑你..:)




it is showing me alert when file exists.
it is running fine in IE but not in chrome.
Becoz ActiveX does not work in chrome.
i got some link for accessing local files in chrome.
http://wizard.ae.krakow.pl/~jb/localio.html[^]

but they have given input file control for opening dialog box which i don''t want.

Thank a lot.
God bless u..:)

推荐答案

你是正确的,ActiveX在chrome中不起作用,它也不适用于Firefox,Opera或任何其他浏览器除了IE。原因是ActiveX允许客户端系统访问Web源,这正是您尝试执行的操作。除了将文件上传到服务器之外,Chrome,Firefox等不允许任何访问客户端系统 - 即使这样您也无法找到源驱动器,文件夹或任何其他信息,因此您将不得不重新考虑您的整个想法如果你想使用IE以外的任何浏览器。即使对于IE,出于安全原因,大多数浏览器安装都不接受或运行ActiveX控件。
You are correct that ActiveX does not work in chrome, it also does not work in Firefox, Opera, or any other browser apart from IE. The reason why is that ActiveX gives access to the client system to web sources, which is exactly what you are trying to do. Chrome, Firefox etc. do not allow any access to the client system other than to upload a file to the server - and even then you cannot find out the source drive, folder or any other information, so you will have to rethink your whole idea if you want to use any browser other than IE. And even for IE, most browser installations do not accept or run ActiveX controls for security reasons.


这篇关于从chrome中的java脚本访问本地文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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