Click to See Complete Forum and Search --> : JavaScript: creating zip files?


phrygius
01-26-2006, 05:44 PM
Does anyone know if javascript is capable of creating zip files?

Thanks,
phrygius

MarkR
01-26-2006, 07:50 PM
Unprivileged client-side Javascript code is not capable of creating FILES, therefore I doubt very much whether it can create zip files.

Privileged code in Mozilla can certainly read from zip files, as the majority of the browser's data is stored in them (jars). Maybe it can write them too. Have a look at XULPlanet.

Client-side script can't create files in MSIE or other browsers either.

Consider creating the file server-side and passing it in a small IFRAME or something (for the client to download)

Mark

phrygius
01-26-2006, 09:19 PM
Hmmm, if it doesnt have privilege to create an actual file, how about creating a zip stream (similar to what java does)?

JPnyc
01-27-2006, 12:09 AM
Well technically it can, depending on how permissions are set and how patched their windows OS and IE are, but odds are no one in this day and age has permissions set that loose. Javascript can instantiate a windows Scripting.fileSystemObject through the use of ActiveX, but like I said, it's probably not going to work anywhere anymore.

phrygius
01-27-2006, 02:42 AM
Okay. Yeah, thats what I was thinking being that there's no documentation anywhere on this subject.

But thanks for the replies MarkR and JPync.

-phrygius

MarkR
01-27-2006, 06:35 AM
Hmmm, if it doesnt have privilege to create an actual file, how about creating a zip stream (similar to what java does)?

I don't think you can usefully do that either. In MSIE, you can pretty much forget using any ActiveX to do this sort of thing - it's supported under restricted circumstances in IE6, but it's blocked by a lot of software firewalls and is likely to be disabled by default in IE7.

Moreover, I don't think the API of either Mozilla or IE scriptable activex controls, provides anything which can do zipfile IO in unprivileged script.

In Mozilla, privileged script *MAY* be able to do it, but that is pretty much a none-starter too.

Mark

Weedpacket
01-27-2006, 06:51 PM
If it is just a zip data stream, then it's just a matter of programming even to do it in pure JS. But I don't think anyone's ever bothered to write such a beast (unlike Java, for which a zlib kit exists in the distributed library).