uploading compressed files (.zip, .tar, .gzip, etc.)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
siu
Forum Newbie
Posts: 3
Joined: Thu May 05, 2005 11:49 pm
Location: San Pedro Sula, Honduras

uploading compressed files (.zip, .tar, .gzip, etc.)

Post by siu »

I wish to know if there is a way to upload a compressed text file such that as it is uploaded, be able to uncompress it via php and manipulate the text files in order to read data and update database with that data. I came with this when I learned that phpMyAdmin can upload compressed .sql files and then restore a mysql database in seconds. Can anybody give me code examples, etc? Any help will be appreciated.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I believe we have a code-snipplet for compressing/de-compressing over at our code snipplet forum.
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

*bumps topic*

I've searched and searched for some sort of file uncompression. Nada. The only thread I found on these forums is this one.

All I want to do is upload a .tar.gz of photos and uncompress it. Can someone point me in the right direction?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Skara,

There's the module ZZipLib for PHP. Then there's also a class ~redmonkey posted in snippets (although I haven't looked at it to check it's for what you need). I guess hotscripts or phpclasses would turn up something too.

BUT, failing those two, you could always just run the unzip command from passthru(), exec() or system() if the only purpose is to physically unzip a file.
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

yeah, I tried using exec() and got permission denied no matter what I did... 777'd every single file in the neighborhood even. O.o

redmonkey's class is just for zip files, as is ZZipLib, if I'm not mistaken.

Found something on phpclasses, though: http://www.phpclasses.org/browse/package/945.html

^_^
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Sometimes chmodding a file 777 will actually cause it to not work. Try 775.
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

O.o This is kinda weird. I chdir()'d to the dir and it worked. Weird. Must have been something I did wrong. :P
Post Reply