note 57206 deleted from ref.curl by mazzanet
| From: | mazzanet@php.net | Date: | Tue, 27 Sep 2005 07:57:43 +0000 |
| Subject: | note 57206 deleted from ref.curl by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-95860@lists.php.net to get a copy of this message | ||
Note Submitter: yns at yns dot zaxaz dot com
----
I did a simple function for downloading files.I hope can bu useful.I use it in my server , almost dl
speed : 400k /sn.
<?
/*
- Yunus Emre Yilmaz
*/
function downloadFile($adres,$ad)
{
if (!extension_loaded(curl)) {
die("Extension yuklu degil socket deneyebilirsin");
}
$ch = curl_init("$adres");
if (!$ch) {
die("Curl oturumu baslatamadim..");
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
// baglantiyi kapa
$islem = fopen("$ad", "a+");
fwrite($islem, $data);
fclose($islem);
if ($islem) {
echo" Dosya basariyla yuklendi...";
} else {
die("Dosya yuklenemedi");
}
}
// Example usage
// downloadFile('http://www.ceviz.net/yns.rar','yns.rar');
?>