下载数据url文件 [英] Download data url file

查看:216
本文介绍了下载数据url文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在玩一个完全基于javascript的zip / unzip实用程序的想法,任何人都可以从浏览器访问。他们可以直接将他们的zip拖到浏览器中,然后让他们下载所有文件。他们还可以通过拖动单个文件来创建新的zip文件。

I'm playing with the idea of making a completely javascript based zip/unzip utility that anyone can access from a browser. They can just drag their zip directly into the browser and it'll let them download all the files within. They can also create new zip files by dragging individual files in.

我知道在服务器端做它会更好,但这个项目只是为了一点乐趣。

I know it'd be better to do it serverside, but this project is just for a bit of fun.

如果我利用各种可用的方法,将文件拖入浏览器应该很容易。 (gmail风格)

Dragging files into the browser should be easy enough if I take advantage of the various methods available. (gmail style)

编码/解码应该没问题。我已经看过一些as3 zip库,所以我相信我应该没问题。

Encoding/decoding should hopefully be fine. I've seen some as3 zip libraries so I'm sure I should be fine with that.

我的问题是在最后下载文件..

My issue is downloading the files at the end..

window.location = 'data:jpg/image;base64,/9j/4AAQSkZJR....' 

这在firefox中运行正常,但在chrome中运行不正常。

this works fine in firefox but not in chrome.

我可以使用< img src =data:jpg / image; ba .../将文件嵌入到Chrome中找到的图像中> ,但文件不一定是图像。它们可以是任何格式。

I can embed the files as images just find in chrome using <img src="data:jpg/image;ba.." />, but the files wont necessarily be images. They could be any format.

任何人都可以想到另一种解决方案或某种解决方法吗?

Can anyone think of another solution or some kind of work around?

推荐答案

想法:


  • 尝试< a href =数据:....target =_ blank> (未经测试)

使用 downloadify 而不是数据URL(也适用于IE)

Use downloadify instead of data URLs (would work for IE as well)

这篇关于下载数据url文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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