Jump to content

haydnw

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

haydnw's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Anyone? More frantic Googling still hasn't helped...
  2. Hi everyone, I have some code which has been successfully zipping up the contents of a folder full of images. However, whilst playing around with some other things on the site, I seem to have broken it! The error message I get is... <b>Warning</b>: ZipArchive::addFile() [<a href='ziparchive.addfile'>ziparchive.addfile</a>]: Invalid or unitialized Zip object in <b><server path to my file>/gallery/includes/classes/hwGallery.php</b> on line <b>195</b><br /> Could anyone please explain what might be causing this? I'm sure the object is being initialised OK, as it's exactly the same code as previously, which worked in the past, although now even that seems to have broken (i.e. uploading an old version of the code, which used to work, also now fails). Could this be a file permissions error? I'm not entirely sure where PHP would be writing the file (does it even do that, or is it all carried out in memory?). Any pointers or helpers would be gratefully received - Google and the search feature on this site haven't turned up anything so far. Thanks, Haydn Code: The code to get the zip file is part of the 'hwGallery' class... /* * Create a ZIP file containing all the images in the gallery * */ public function getZipFile() { // Partially taken from http://ubuntuforums.org/showthread.php?t=859477 // Zip file header header("Content-Type: application/zip"); header('Content-Disposition: attachment; filename="gallery.zip"'); // Create actual Zip file $zipFile = new ZipArchive(); $zipFile->open("download.zip", ZipArchive::OVERWRITE); foreach ($this->imagePaths as $imageFile) { if (strpos($imageFile,"index") == false) { $zipFile->addFile($imageFile); } } $zipFile->close(); // Return the ZIP file, then delete it echo file_get_contents("download.zip"); unlink("download.zip"); } which is called in the following manner: $gallery = new hwGallery($id); $gallery->getZipFile();
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.