Jump to content

downloading a zip through php script


mattykewl

Recommended Posts

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

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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.