Hello,
I'm using the zziplib to unpack a large (10M) file that contains about 200 pdf's.
When I run the script, it unzips everything apparently without a problem. But then when I go and view one of the pdf's it gives me an error that the file is corrupt; acrobat cannot load it.
I have verified that the pdf and the zip file are indeed OK -- by unzipping them into another directory from the command line with unzip.
The code I used comes pretty much straight from the php manual ... Does anyone have some insight on this, or can someone direct me to another option to work with zip files??
Thanks
Frizzo
$zipfile = "batch1.zip";
$zip = zip_open($zipfile);
while ($zip_entry = zip_read($zip)) {
$m_filename = zip_entry_name($zip_entry);
if (zip_entry_open($zip, $zip_entry, "r")) {
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
zip_entry_close($zip_entry);
save_zip("/usr2/home/test/" . $m_filename, $buf);
}
}
zip_close($zip);
function save_zip($filename, $data){
if (!$fp = fopen ($filename, "w")){
die("could not open file" . getcwd());
}
fputs($fp, $data);
fclose($fp);
}