views:

27

answers:

2

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.

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

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....' 

this works fine in firefox but not in 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?

+1  A: 

Ideas:

  • Try a <a href="data:...." target="_blank"> (Untested)

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

Pekka
Thanks. Two good suggestions.
Mikee
A: 

Your problem essentially boils down to "not all browsers will support this".

You could try a workaround and serve the unzipped files from a Flash object, but then you'd lose the JS-only purity (anyway, I'm not sure whether you currently can "drag files into browser" without some sort of Flash workaround - is that a HTML5 feature maybe?)

Piskvor