SORU
20 HAZİRAN 2011, PAZARTESİ


İndirme büyük bir dosya curl kullanarak

Uzak dosya curl kullanarak indirmek istiyorum.

İşte ben örnek kod:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$st = curl_exec($ch);
$fd = fopen($tmp_name, 'w');
fwrite($fd, $st);
fclose($fd);

curl_close($ch);

Ama bellek onu okur, çünkü büyük dosyaları işlemek.

Doğrudan diske dosya stream mümkün mü?

CEVAP
20 HAZİRAN 2011, PAZARTESİ


<?php
set_time_limit(0);
$fp = fopen (dirname(__FILE__) . '/localfile.tmp', 'w ');//This is the file where we save the    information
$ch = curl_init(str_replace(" "," ",$url));//Here is the file we are downloading, replace spaces with  
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
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);
?>

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Day9TV

    Day9TV

    22 NİSAN 2010
  • Eric Enge

    Eric Enge

    2 Kasım 2009
  • maxman.tv

    maxman.tv

    29 EKİM 2013