regoch Posted August 3, 2011 Share Posted August 3, 2011 I got this script for create zip. <?php /* creates a compressed zip file */ function create_zip($files = array(),$destination = '',$overwrite = false) { //if the zip file already exists and overwrite is false, return false if(file_exists($destination) && !$overwrite) { return false; } //vars $valid_files = array(); //if files were passed in... if(is_array($files)) { //cycle through each file foreach($files as $file) { //make sure the file exists if(file_exists($file)) { $valid_files[] = $file; } } } //if we have good files... if(count($valid_files)) { //create the archive $zip = new ZipArchive(); if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) { return false; } //add the files foreach($valid_files as $file) { $zip->addFile($file,$file); } //debug //echo 'The zip archive contains ',$zip->numFiles,' files with a status of ',$zip->status; //close the zip -- done! $zip->close(); //check to make sure the file exists return file_exists($destination); } else { return false; } } $files_to_zip = array( 'images/black.png', 'images/white.png' ); //if true, good; if false, zip creation failed $result = create_zip($files_to_zip,'my-archive.zip'); ?> I keep getting this error. Fatal error: Class 'ZipArchive' not found in I search google and find that i must have PHP 5.2. I have PHP Version 5.2.16. http://www.pkzadar.hr/recurseZip/example.php There is link with my php info. Any idea why this happening? Link to comment https://forums.phpfreaks.com/topic/243685-create-zip/ Share on other sites More sharing options...
ram4nd Posted August 3, 2011 Share Posted August 3, 2011 (PHP 5 >= 5.2.0, PECL zip >= 1.1.0) Link to comment https://forums.phpfreaks.com/topic/243685-create-zip/#findComment-1251150 Share on other sites More sharing options...
Muddy_Funster Posted August 3, 2011 Share Posted August 3, 2011 No idea, unless you havn't enabled it in your php.ini file http://www.php.net/manual/en/zip.installation.php Link to comment https://forums.phpfreaks.com/topic/243685-create-zip/#findComment-1251155 Share on other sites More sharing options...
silkfire Posted August 3, 2011 Share Posted August 3, 2011 Check in your phpinfo() file and look for the zip module: Link to comment https://forums.phpfreaks.com/topic/243685-create-zip/#findComment-1251171 Share on other sites More sharing options...
regoch Posted August 3, 2011 Author Share Posted August 3, 2011 Don't have zip module, how to install it? [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/243685-create-zip/#findComment-1251277 Share on other sites More sharing options...
Muddy_Funster Posted August 3, 2011 Share Posted August 3, 2011 I linked to the install instructions in my last post.... Link to comment https://forums.phpfreaks.com/topic/243685-create-zip/#findComment-1251282 Share on other sites More sharing options...
regoch Posted August 4, 2011 Author Share Posted August 4, 2011 Can't open that link. I download zip from http://pecl.php.net/package/zip I don't know how to install it?Is therea way through cpanel or copy via ftp? Here is my ftp screenshot, if there a folder to copy it? [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/243685-create-zip/#findComment-1251913 Share on other sites More sharing options...
silkfire Posted August 4, 2011 Share Posted August 4, 2011 There's a better Zip module out there that does not require installation. PM me your email and I'll send you the Class file along with instructions. Link to comment https://forums.phpfreaks.com/topic/243685-create-zip/#findComment-1251936 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.