public function download($url, $handler, $path = null)
    {
        $result = $this->transferred = null;
        $this->hook->attach('file.download.before', $url, $handler, $path, $result, $this);

        if (isset($result)) {
            return $result;
        }

        $this->setHandler($handler);
        $this->setDestination($path);

        try {
            $temp = $this->downloadTempFile($url);
        } catch (Exception $ex) {
            return $ex->getMessage();
        }

        try {
            $this->validateHandler($temp);
        } catch (Exception $ex) {
            unlink($temp);
            return $ex->getMessage();
        }

        try {
            $result = $this->finalize($temp, $this->destination, false);
        } catch (Exception $ex) {
            $result = $ex->getMessage();
        }

        $this->hook->attach('file.download.after', $url, $handler, $temp, $result, $this);
        return $result;
    }
public function download($url, $handler, $path = null)
    {
        $result = $this->transferred = null;
        $this->hook->attach('file.download.before', $url, $handler, $path, $result, $this);

        if (isset($result)) {
            return $result;
        }

        $this->setHandler($handler);
        $this->setDestination($path);

        try {
            $temp = $this->downloadTempFile($url);
        } catch (Exception $ex) {
            return $ex->getMessage();
        }

        try {
            $this->validateHandler($temp);
        } catch (Exception $ex) {
            unlink($temp);
            return $ex->getMessage();
        }

        try {
            $result = $this->finalize($temp, $this->destination, false);
        } catch (Exception $ex) {
            $result = $ex->getMessage();
        }

        $this->hook->attach('file.download.after', $url, $handler, $temp, $result, $this);
        return $result;
    }
public function download ( $ url , $ handler , $ path = null ) { $ result = $ this -> transferred = null ; $ this -> hook -> attach ( 'file.download.before' , $ url , $ handler , $ path , $ result , $ this ) ; if ( isset ( $ result ) ) { return $ result ; } $ this -> setHandler ( $ handler ) ; $ this -> setDestination ( $ path ) ; try { $ temp = $ this -> downloadTempFile ( $ url ) ; } catch ( Exception $ ex ) { return $ ex -> getMessage ( ) ; } try { $ this -> validateHandler ( $ temp ) ; } catch ( Exception $ ex ) { unlink ( $ temp ) ; return $ ex -> getMessage ( ) ; } try { $ result = $ this -> finalize ( $ temp , $ this -> destination , false ) ; } catch ( Exception $ ex ) { $ result = $ ex -> getMessage ( ) ; } $ this -> hook -> attach ( 'file.download.after' , $ url , $ handler , $ temp , $ result , $ this ) ; return $ result ; }
Downloads a file from a remote URL
@param string $url
@param null|false|string $handler
@param string|null $path
@return mixed
Downloads a file from a remote URL