Browse Source

import

master
jcabillot 6 years ago
parent
commit
3e4465f8ca
1 changed files with 23 additions and 0 deletions
  1. 23
      lib/Download.php

23
lib/Download.php

@ -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'));
Loading…
Cancel
Save