Hello-
I am trying to use the following code to read a zip file, and then save each file within the zip file onto my system. The web server is running RedHat, and I have ZZIPLIB installed. Could anyone shed some light on why the following code is not working?
function WriteFile($outfile,$writestring)
{
$fp = fopen($outfile, "w+");
fputs($fp, $writestring);
fclose($fd);
}
function ExtractZIPFile($zip_fname,$dir)
{
$stamp = date("D m/d/y @ h:i:s A");
$zip = zip_open($zip_fname);
if($zip):
while($zip_entry = zip_read($zip)):
$fname = zip_entry_name($zip_entry);
$fsize = zip_entry_filesize($zip_entry);
if(zip_entry_open($zip, $zip_entry, "r")):
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
$dest = "$dir/$fname";
WriteFile($dest,$buf);
zip_entry_close($zip_entry);
endif;
endwhile;
//close zip file
zip_close($zip);
else:
echo "error opening zip!";
endif;
}
Any help would be greatly appreciated!
Bryan