botla çekilen resmi hosta kaydetme ?
2
●813
- 07-04-2009, 21:06:55
<?php class fileDownload { private $fileURL; private $file; private $dir; private $curl; private $return = array(); private $content; public function __construct($url) { $this->fileURL = $url; } public function setDirectory($name) { if (!is_writable($name) || !is_readable($name)) { exit('<ul>'.$name.' Hatası.<li>Dizin Okuma Modunda Değil</li><li>Dizin Yazma Modunda Değil</li></ul>'); } else { $this->dir = $name; } } protected function getData() { $this->curl = curl_init(); curl_setopt($this->curl,CURLOPT_URL, $this->fileURL); curl_setopt($this->curl,CURLOPT_RETURNTRANSFER,1); $this->content = curl_exec($this->curl); curl_close($this->curl); } public function saveData() { preg_match("#http:\/\/.*\/(.*)#i",$this->fileURL,$this->return); $this->getData(); $this->file = fopen($this->dir."/".$this->return[1],"w"); if (fwrite($this->file,$this->content)) { return true; } else { return false; } } } ?>kullanımı :
$link = "http://www.google.com.tr/intl/en_com/images/logo_plain.png"; $file = new fileDownload($link); $file->setDirectory('upload'); if ($file->saveData()) { echo "Dosya download edildi."; } else { echo "Dosya download edilemedi. Yeniden Deneyiniz.";CURL yüklü olması gerekir.
işini görür herhalde - 07-04-2009, 21:19:45uysal_rockci adlı üyeden alıntı: mesajı görüntüle
çok teşekkürler çok zamandır bunla uğraşıyodum sonunda oldu