Currently wondering if anyone has experienced corrupt zip files. I'm currently using the following code
// Multiple File Downloads
require_once('includes/pclzip.lib.php');
$archive = new PclZip('archive.zip');
$v_list = $archive->create('robots.txt,index.php');
if ($v_list == 0) {
die("Error : ".$archive->errorInfo(true));
}
$file_url = 'archive.zip';
header('Content-Type: application/zip');
header("Content-disposition: attachment; filename=\"" . basename($file_url) . "\"");
readfile($file_url);
To create a zip archive and force the zip download, eventually this will be initiated by a button click but for now I'm simply trying to create an archive that actually works.
I'm getting the issue regardless of whether or not I use the built in ZipArchive
class or use the PclZip
library.
One thing that's very odd is that the zip that's created and placed on the server works just fine when I downloaded it via FileZilla but all bets are off once if I force the file downloaded. I've tried in multiple browsers and the results are the same for each.
Really annoying. I'll admit that this is my first time attempting to implement this type of functionality so perhaps I'm missing something. I've seen a few threads on similar issues but unfortunately the solutions are not working for me. Any help that can be provided would be much appreciated.