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.
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.
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.
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').
it's not working, so I guess my server configuration doesn't allow it. any other suggestions?
sounds like php doesnt have write permissions.
is the directory youre trying to create the zip in, writiable by php?
it's the file i'm trying to create
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?
you cant use ftp and look?
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?
This topic is now closed. New replies are no longer allowed.