Welcome Guest, Not a member yet? Register   Sign In
Download file with curl

Greetings, I'm trying to download a file with curl Seller codeigniter, but I could not save the contents of the file, the code is as follows:


//he jugado con todas estas opciones que estan comentadas y nada
//$this->curl->option('buffersize', 10);
//$this->curl->option('useragent', 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv: Gecko/20100722 Firefox/3.6.8 (.NET CLR 3.5.30729)');
//$this->curl->option('returntransfer', 1);
//$this->curl->option('followlocation', 1);
//$this->curl->option('connecttimeout', 600);

//por si a traves de la aplicacion quiero utilizar un proxy para descargar el fichero
if ($options[0]->proxy_use == "1") {
$this->curl->proxy($options[0]->proxy, $options[0]->proxy_port);
$this->curl->proxy_login($options[0]->proxy_user, $options[0]->proxy_pass);

$carpeta = $value->ext;
$dir = $options[0]->path_to_save . "/" . $carpeta;
if (!is_dir($dir)) {//si no existe la direccion
$fp = fopen($dir . "/" . $value->name . "." . $value->ext, 'w');
$this->curl->option('file', $fp);
$this->curl->option('connecttimeout', 60);
//fwrite($fp, $descarga);
} else {
$fp = fopen($dir . "/" . $value->name . "." . $value->ext, 'w');
$this->curl->option('file', $fp);
$this->curl->option('connecttimeout', 60);
//fwrite($fp, $descarga);

$descarga = $this->curl->execute();
$info = $this->curl->info;

The idea is that when the file is supposed to go down there to check if a certain location a folder with the extension of the file and inside that folder to save the file, but I only creates a file with a size 0.

It appears that the content of the doc not this fall.


Theme © iAndrew 2016 - Forum software by © MyBB