How to zip a directory with PHPHello, I’ve a little question to admin, how to get all files in a directory (or sub directory in it) in a PHP array? I actually want to compress or zip entire directory. I use the following function.Code
function download($filearray)
{
$filename='backup.zip';
$zip = new ZipArchive;
$res = $zip->open($filename, ZipArchive::CREATE);
if($res !== TRUE){die('Error: Unable to create zip file');}
foreach($filearray as $file){$zip->addFile($file);}
$zip->close();
@header("Location: $filename");
exit;
}
|
| Posted by: argo; Post:2; Comments:1; Date of Join: Nov 09, 2009, 14:04 Post date: Nov 09, 2009, 17:35 |
| New topicReplyContactReport |
Re: How to zip a directory with PHPThank you for posting this useful topic. First of all I mention that you do not require that name array to zip a directory. Instead you can use the recursive function to do the job. Please read this article:PHP Zip files and directory ----------------------------------------------------------- |
| Posted by: admin; Post:34; Comments:116; Date of Join: Nov 05, 2008, 08:04 Post date: Nov 14, 2009, 18:09 |
| ContactReport |