lobsterman — 2006-09-04T12:48:44-04:00 — #1
I'm looking for a way to zip folders with php and provide a download link to them. any ideas?
I tried PclZip, but I get errors, and I don't really know how to solve them, cause I've never worked with zips before.
jake_arkinstall — 2006-09-04T13:02:41-04:00 — #2
talence — 2006-09-04T13:07:06-04:00 — #3
Can you use this:
exec("tar -c sourcefolder destinationfolder.tar.gz");
this will work only if you server support exec() function or not having safe_mode enabled.
lobsterman — 2006-09-04T13:39:26-04:00 — #4
Here's my error "Error : PCLZIP_ERR_READ_OPEN_FAIL (-2) : Unable to open archive 'Transparentia.zip' in wb mode"
Using this code:
//download library from http://www.phpconcept.net/pclzip/index.en.php#download
//zip file name
$new_zip= new PclZip('backup.zip');
//backup theimages folder
$file_list = $new_zip->create('images/');
if ($file_list == 0)
die("Error : ".$new_zip->errorInfo(true));
echo "Successfully created zip file";
which I found at a site.
I double checked, it's loading the pclzip.lib.php file, so that's not the problem.
talence: It needs to be zip, so that it's user friendly.
php_daemon — 2006-09-04T14:04:37-04:00 — #5
Try zip if it's available:
exec("zip -r output/files.zip path/to/dir");
Make sure you set the right permissions for the destination directory (in this case 'output').
lobsterman — 2006-09-04T14:21:59-04:00 — #6
it's not working, so I guess my server configuration doesn't allow it. any other suggestions?
clamcrusher — 2006-09-04T14:24:45-04:00 — #7
sounds like php doesnt have write permissions.
is the directory youre trying to create the zip in, writiable by php?
lobsterman — 2006-09-04T14:28:49-04:00 — #8
it's the file i'm trying to create
lobsterman — 2006-09-04T14:39:49-04:00 — #9
ok, i changed the permissions, and now it says "Successfully created zip file", but i don't know where it put it... anyone use this script before?
clamcrusher — 2006-09-04T14:45:03-04:00 — #10
you cant use ftp and look?
lobsterman — 2006-09-04T14:57:48-04:00 — #11
ok, i found it, in the directory the script was in, but i cant figure out how to change that, plus it zips up the whole directory structure, from the server root, which isn't desirable.
Anyone know some simple tutorial/script/library with clear instructions in readable english?