Dear all,

I am trying to create a zipping mechanism that allows the user to select a
number of files from a list; these files are then zipped and downloaded to
the user's machine. I presently have:

$zip = new ZipArchive();                
$filename = $zipfinalpath."tutor/zipfiles/".$tutorzipfile;
                
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
        exit("cannot open <$filename> \n");
}
else {
        $loopCount = 0;
        foreach ($filelisttozip as $i => $fileValue) {  
                //the 
                $zip->addFile($fileValue,$filenamelisttozip[$loopCount]);
                $loopCount ++;
        }
}
                                
$zip->close();

In my test sample of files I have the following file types:

.doc
.zip
.jpg
.doc

And the zip mechanism works when I ask for all or omit any of the files from
the list, except when I omit the zip file! E.g.

1. Asking for all works
2. Asking for .zip,.jpg,.doc works
3. Asking for .doc,.zip works
4. Asking for .doc,.jpg,.doc doesn't work - 7-zip tells me that the file is
not support archive and windows tells me the Compressed(folder) is invalid
or corrupted!

I have used different zip files to make sure that it's not the file, but all
to no avail. . .but if I add:

$zip = zip_open($filename);
while ($zip_entry = zip_read($zip)) {
      $file = basename(zip_entry_name($zip_entry));
                        
        echo 'a'.$file.'<br>';
}
zip_close($zip);

to the bottom of my page it correctly displays, on screen, the 3 files I
expect to be in the zip file.

Any help would be very gratefully received as this is driving me mad!!!

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to