mattykewl Posted January 26, 2007 Share Posted January 26, 2007 Can someone help me, i need to download a zip file off the server using php and save it to a certain destination on another server, i can do this in a few lines of code right?also, how can i go about extracting the zip files after they've downloaded, again using solely php code, i dont want to use cron or wget must be php only. thanks in advance Link to comment https://forums.phpfreaks.com/topic/35859-downloading-a-zip-through-php-script/ Share on other sites More sharing options...
genericnumber1 Posted January 26, 2007 Share Posted January 26, 2007 You can download a file using file_get_contents() and fopen() + fwrite() to paste the contents into a new fileas for unzipping you'll wanna take a look at the zip functions... http://www.php.net/zip Link to comment https://forums.phpfreaks.com/topic/35859-downloading-a-zip-through-php-script/#findComment-169985 Share on other sites More sharing options...
mattykewl Posted January 26, 2007 Author Share Posted January 26, 2007 Thanks for the reply, i should if mentioned ive been trying these but ive not had any luck on the syntax side, can you provide me an example? Link to comment https://forums.phpfreaks.com/topic/35859-downloading-a-zip-through-php-script/#findComment-169988 Share on other sites More sharing options...
genericnumber1 Posted January 26, 2007 Share Posted January 26, 2007 I'm not sure on the zip functions, I've never looked into them as of yet... downloading the file is simple[code=php:0]$copyFrom = "http://www.websitetocopyfrom.com/";$pasteTo = "/location/to/paste/to/";$contents = file_get_contents($copyFrom);$handle = fopen($pasteTo, 'w');if ( !fwrite($handle, $contents) ) { echo 'Copy unsuccessful.';} else { echo 'Success!';}[/code] Link to comment https://forums.phpfreaks.com/topic/35859-downloading-a-zip-through-php-script/#findComment-170047 Share on other sites More sharing options...
mattykewl Posted January 26, 2007 Author Share Posted January 26, 2007 hmm thanks, somethings happening, it says successful but nothing appears to the dir it saves at :| Link to comment https://forums.phpfreaks.com/topic/35859-downloading-a-zip-through-php-script/#findComment-170075 Share on other sites More sharing options...
genericnumber1 Posted January 26, 2007 Share Posted January 26, 2007 well you have to specify a file name, I should have been more exact....[code=php:0]$pasteTo = "/location/to/paste/to.zip";[/code] Link to comment https://forums.phpfreaks.com/topic/35859-downloading-a-zip-through-php-script/#findComment-170078 Share on other sites More sharing options...
mattykewl Posted January 26, 2007 Author Share Posted January 26, 2007 THANK YOU SO MUCH! Link to comment https://forums.phpfreaks.com/topic/35859-downloading-a-zip-through-php-script/#findComment-170082 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.