获取本地文件内容而不上传

发布于 2024-12-14 13:54:59 字数 132 浏览 3 评论 0原文

我正在编写一个离线网络应用程序,允许用户选择本地文件,修改它,然后也在本地保存副本。是否可以在没有任何服务器的情况下(我可以上传文件并返回其base64,但它不是离线的)?应用程序只需要在 Google Chrome 上运行,所以也许我应该看看这里?

I'm writing an offline webapp that allows user to select local file, modify it and than saves a copy also locally. Is it possible without any server (I can upload a file and return base64 of it, but it's not much of a offline)? App needs to work only on Google Chrome, so maybe I should look here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

許願樹丅啲祈禱 2024-12-21 13:54:59
 input = document.getElementById(inputId);          

 var reader = new FileReader();

 reader.onload = function (e) {
     base64 = e.target.result;
 };

 reader.readAsDataURL(input.files[0]);

其中 input 是一个元素 。也适用于可以选择多个文件的输入。

 input = document.getElementById(inputId);          

 var reader = new FileReader();

 reader.onload = function (e) {
     base64 = e.target.result;
 };

 reader.readAsDataURL(input.files[0]);

where input is an element <input type='file'></input>. Also works for an input that can select multiple files.

末蓝 2024-12-21 13:54:59

为了在浏览器中处理文件,我使用 downloadify。为了使其能够与包含“file://”的路径一起使用,您需要允许 downloadify.swf 访问 设置

To work with files in the browser I use downloadify. In order to make it work with paths containing "file://" you need to allow for downloadify.swf access to the file system on the settings.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文