使用jquery在客户端读/写文本文件 [英] Read/write text file at client side using jquery

查看:322
本文介绍了使用jquery在客户端读/写文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想在客户端的PC上读取和写入文本文件,第三方桌面应用程序可以从那里读取该文件。



请指导我如何使用jquery或javascript读取/写入文本文件到客户端的PC。



Chrome浏览器将在Window或Mac OS中使用。



谢谢。

解决方案

你不能。



出于安全考虑,您的网站无法在客户端计算机上读取或写入文件。想一想:如果你能做到,那么恶意网站就可以......


如果你想在没有某种形式的用户交互的情况下阅读文件,那你就不走运了。 JavaScript始终在浏览器的沙箱中运行,并且无法访问沙箱之外的任何资源。这样做是出于安全原因。


但是,如果您的用户选择要处理的文件,您可以查看大多数现代浏览器支持的JS的File API。 https://developer.mozilla.org/en-US/docs/Web/API/File [ ^ ]

Hi,

I want to read and write text file on client's PC from where 3rd party desktop application can able to read that file.

Please guide me on how to read/write text file to the client's PC using jquery or javascript.

Chrome browser will be used in Window or Mac OS.

Thanks.

解决方案

You can't.

Your website has no access to reading or writing files on your client computer for security reasons. Think about it: if you could do it, so could malicious sites...


If you are wanting to read the file without some form of user interaction, you are out of luck. JavaScript always runs in the "sandbox" of the browser and does not have access to any resources outside of the sandbox. This is done for security reasons.

However if your users are selecting files for processing you could look at the File API for JS that most modern browsers support. https://developer.mozilla.org/en-US/docs/Web/API/File[^]


这篇关于使用jquery在客户端读/写文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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