Unzip to directory
Posted: Wed Jan 13, 2010 12:14 am
Grabbed this over at PHP.net, and I have a good understanding of PHP, but this is eluding me. What I'm doing is trying to set up a content management system for a gallery portion of a flash site I'm making, and this would make everyones lives easier. Ideally he would upload a zip of the images and PHP/Flash would do the rest. Once I get the syntax for getting these files out of the zip and into the folder I want I can take it from there.
I tried adjusting some of the fopen and fwrite, but no go. This is just a little over my head.
Any suggestions?
Thanks
Code: Select all
$zip = zip_open($zipfile);
while ($zip_entry = zip_read($zip)){
zip_entry_open($zip, $zip_entry);
$name = zip_entry_name($zip_entry);
if (file_exists($name)) {
trigger_error('File "<b>' . $name . '</b>" exists', E_USER_ERROR);
return false;
}
$fopen = fopen($newName, "w");
fwrite($fopen, zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)), zip_entry_filesize($zip_entry));
zip_entry_close($zip_entry);
}
Any suggestions?
Thanks