|
|
|
@ -0,0 +1,23 @@ |
|
|
|
<?php |
|
|
|
|
|
|
|
class Download { |
|
|
|
/** |
|
|
|
* Telecharge depuis $url vers $out. |
|
|
|
* |
|
|
|
* @param string $url URL a telecharger |
|
|
|
* @param string $out Fichier de destination |
|
|
|
*/ |
|
|
|
static function get($url, $out) { |
|
|
|
set_time_limit(0); |
|
|
|
$fp = fopen($out, 'w+');//This is the file where we save the information
|
|
|
|
$ch = curl_init($url);//Here is the file we are downloading, replace spaces with %20
|
|
|
|
curl_setopt($ch, CURLOPT_FILE, $fp); // write curl response to file
|
|
|
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
|
|
curl_exec($ch); // get curl response
|
|
|
|
curl_close($ch); |
|
|
|
fclose($fp); |
|
|
|
// TODO : retourner info duree transfert
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//var_dump(Download::get('https://dl.sdv.fr/files/0/6/7/rubygem-csscss-1.0.0-1.fc18.src.rpm', 'Archive.zip'));
|