简体   繁体   English

如果我不关心安全性,是否可以通过客户端编程(特别是JS)进行文件IO?

[英]If I don't care about security, is there a way to do file IO with client side programming (specifically, JS)?

I realize this is a HUGE , MASSIVE security risk, but I have my reasons. 我意识到这是巨大的大规模的安全风险,但是我有自己的理由。 I'm not asking whether it's a good idea, just whether it is possible at all. 我不是在问这是否是个好主意,只是问是否有可能。 Doesn't necessarily need to be JS, but it does need to be browser based and client side. 不一定需要是JS,但确实需要是基于浏览器和客户端的。

Specifics: 细节:

  1. Client must be able to create and write to server-side file. 客户端必须能够创建并写入服务器端文件。
  2. Cross browser/platform solution is preferred, but solutions specific to one environment would also be good. 最好使用跨浏览器/平台的解决方案,但是特定于一种环境的解决方案也不错。
  3. Preferably the solution would not require anything beyond the browser's default state, but if it requires some plugin(s) to work, so be it. 最好,该解决方案不需要浏览器默认状态以外的任何东西,但是如果它需要某些插件才能工作,就可以了。

And @Cheeso, definitely not a virus. 还有@Cheeso,绝对不是病毒。 This is more theoretical than anything at this point. 在这一点上,这比理论上的要重要。

Do you speak HTML5? 您会说HTML5吗? Can you force your users to use Google Chrome? 您可以强迫用户使用Google Chrome吗? You can use the filesystem API: here you can find what you need to start reading/writing files . 您可以使用文件系统API: 在这里您可以找到开始读取/写入文件所需的内容

You just added "read and write to a server -side file" to your description... and that's a HUGELY different question. 您刚刚在描述中添加了“读写服务器端文件” ...这是一个完全不同的问题。

If you want to read/write a client -side file, and you can't just have a file upload/download like normal websites, you should look into using a signed Java applet (see this website for details) - IIRC Facebook used such an applet in its early days so users could upload multiple photos at a time. 如果您想读取/写入客户端文件,而不能像普通网站那样仅上传/下载文件,则应考虑使用签名的Java小程序(有关详细信息,请访问此网站 )-IIRC Facebook使用了一个小应用程序,因此用户可以一次上传多张照片。 Java applets seem to be going the way of the dodo, though, so YMMV. 但是,Java applet似乎正像dodo一样。

But if you want to read/write a server -side file, then just about any server will be able to do that, without any browser-side trickery. 但是,如果您想读取/写入服务器端文件,那么几乎任何服务器都可以做到这一点,而无需任何浏览器端的麻烦。 Google is your friend, ie look up "PHP write to file." Google是您的朋友,即查找“ PHP写入文件”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否有某种方法可以将变量(特别是映射)从服务器端导入客户端(Socket.io)? - Is there some way of importing a variable(specifically map) from the server side onto the client side(Socket.io)? JS:当您不关心返回值时,如何解决 promise 问题? - JS: What to a resolve a promise to when you don't care about the return value? 在 JavaScript ES8 async/await 中,如何取消等待那些我不关心的? - In JavaScript ES8 async/await, how to unwait those I don't care about? Socket.io - 不允许客户端使用main.js文件查看文件 - Socket.io - Don't allow client to view files with the main.js file How To Do JavaScript Object 面向客户端编程的正确方法? - How To Do JavaScript Object Oriented Programming client side The Right Way? 为什么我没有看到来自socket.io-client和node.js的响应? - Why don't I see a response from socket.io-client with node.js? 期待一个玩笑测试来解决,但不关心价值 - Expect a jest test to resolve, but don't care about the value 当你不关心错误时,等待和异步 - await & async when you don't care about errors 将GET请求发送到HTTP服务器;不关心反应 - Send GET Request to HTTP Server; don't care about the response Socket.IO 客户端 .js 文件位于何处? - Where is the Socket.IO client-side .js file located?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM