• 07-04-2009, 20:14:05
    #1
    arkadaşlar botlarımda bir problem yok sadece bu hosta veri kaydetme olayını bulamadım bir türlü ufak bir örnekte ustalarımız gösterebilirse çok sevinirim..
  • 07-04-2009, 21:06:55
    #2
    <?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:45
    #3
    uysal_rockci adlı üyeden alıntı: mesajı görüntüle
    <?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

    çok teşekkürler çok zamandır bunla uğraşıyodum sonunda oldu