hackalive Posted December 30, 2010 Share Posted December 30, 2010 Hi guys, I have some code for xtracting the contets of a zip file to a folder. Now this is the code: function extractupdate($file){ $zip = zip_opne("$file"); if(is_resource($zip)){ while ($zip_entry = zip_read($zip)){ $fp = fopen("zip/".zip_entry_name($zip_entry), "w"); if(zip_entry_open($zip, $zip_entry, "r")){ $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); fwrite($fp,"$buf"); zip_entry_close($zip_entry); fclose($fp); } } zip_close($zip); } } My question is how do I install the ZIP library into PHP. At the moment I am using PHP on Windows and using Apache, so I need a good way to add the ZIP library where I edit the php.ini etc.. Your help is much appreciated, thanks. Quote Link to comment Share on other sites More sharing options...
trq Posted December 30, 2010 Share Posted December 30, 2010 On windows you should be able ti simply un-comment the line relating to the php_zip.dll extension within your ini file then restart the server. Quote Link to comment Share on other sites More sharing options...
hackalive Posted December 30, 2010 Author Share Posted December 30, 2010 Thanks thorpe, I have now done that. So this is the "topology" of the code/files: root/index.php $dir = opendir ("temp"); while (false !== ($file = readdir($dir))) { if (strpos($file, '.zip',1)) { extractupdate($file); } } function extractupdate($file){ $zip = zip_open("$file"); if ($zip){ while ($zip_entry = zip_read($zip)){ $update = rtrim($file, ".zip"); $fp = fopen("zip/".zip_entry_name($zip_entry), "w"); if(zip_entry_open($zip, $zip_entry, "r")){ $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)); fwrite($fp,"$buf"); zip_entry_close($zip_entry); fclose($fp); } } zip_close($zip); } } in root/temp/ there is a file 001.zip the code is failing to extract to root/temp/zip/ Any help is much appreciated, thanks. PS My aim is to extract the contents of the zip archive to the folder root/temp/zip/ Cheers Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.