fluid Posted March 11, 2010 Share Posted March 11, 2010 Hi I am trying to grab a remote zip file then extract it but it is trying to extract it before it has trasnfered so I end up with a complete zip file but an xml file of 0 bytes. The code I have is: // read the file $image = file_get_contents("http://www.examplesite.com/zip"); // write the file file_put_contents("zips/filename.zip", $image); // extract the file $zip = zip_open("zips/filename.zip"); if ($zip) { while ($zip_entry = zip_read($zip)) { $fp = fopen("zips/".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); } Many thanks for any help. Link to comment https://forums.phpfreaks.com/topic/194889-extract-a-remote-zip-file-with-php/ Share on other sites More sharing options...
fluid Posted March 11, 2010 Author Share Posted March 11, 2010 had a suggestion on another forum to change file_put_contents("zips/filename.zip", $image); to file_put_contents("zips/window.zip", $image, FILE_APPEND|LOCK_EX); but hasn't worked. Link to comment https://forums.phpfreaks.com/topic/194889-extract-a-remote-zip-file-with-php/#findComment-1024764 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.