简体   繁体   English

浏览器加载本地文件而不上传

[英]browser load local file without upload

Is it possible to edit a local file without uploading to the browser? 是否可以编辑本地文件而无需上传到浏览器?

Let's say the client has an HTML file, I want him to be able to use my site's javascript to edit the file without uploading it. 假设客户端有一个HTML文件,我希望他能够使用我网站的javascript编辑文件而不上传它。 Would this be possible? 这可能吗?

Thanks. 谢谢。

Yes, it is possible, but only in HTML5 (and only as browsers add support for it...not all do yet), you can find the HTML5 File API here . 是的,这是可能的,但仅限于HTML5(并且只有当浏览器添加对它的支持时......并非所有人都支持), 您可以在此处找到HTML5文件API

Note that the user has to give permission to access the file, from Section 5.9 : 请注意,用户必须授予访问该文件的权限, 从第5.9节开始

Once a user has given permission , user agents should provide the ability to read and parse data directly from a local file programmatically. 用户授予权限后 ,用户代理应提供以编程方式直接从本地文件读取和解析数据的功能。

Nope, that's not possible and shouldn't be either due to security concerns it may pose otherwise. 不,这是不可能的, 也不应该是由于它可能造成的安全问题。

Note: This feature is there in HTML5 as pointed out by @Nick Craver , you may want to go for but you should be aware of the fact that HTML5 isn't yet supported by all browsers. 注意: @Nick Craver指出HTML5中有这个功能,你可能想 要这样做 ,但你应该知道所有浏览器都不支持HTML5这一事实。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM