To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > PHP Help > Coding

Coding Help with PHP coding

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 03-11-2010, 08:19 AM   #1
fluid
Junior Member
 
Join Date: Mar 2010
Posts: 1
extract a remote zip file with php

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.
fluid is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 08:03 AM.








Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.