CRemoteImage.php
public function save()
    {
        $this->cache = array();
        $date         = $this->http->getDate(time());
        $maxAge       = $this->http->getMaxAge($this->defaultMaxAge);
        $lastModified = $this->http->getLastModified();
        $type         = $this->http->getContentType();

        $this->cache['Date']           = gmdate("D, d M Y H:i:s T", $date);
        $this->cache['Max-Age']        = $maxAge;
        $this->cache['Content-Type']   = $type;
        $this->cache['Url']            = $this->url;

        if ($lastModified) {
            $this->cache['Last-Modified'] = gmdate("D, d M Y H:i:s T", $lastModified);
        }

        // Save only if body is a valid image
        $body = $this->http->getBody();
        $img = imagecreatefromstring($body);

        if ($img !== false) {
            file_put_contents($this->fileName, $body);
            file_put_contents($this->fileJson, json_encode($this->cache));
            return $this->fileName;
        }

        return false;
    }
public function save()
    {
        $this->cache = array();
        $date         = $this->http->getDate(time());
        $maxAge       = $this->http->getMaxAge($this->defaultMaxAge);
        $lastModified = $this->http->getLastModified();
        $type         = $this->http->getContentType();

        $this->cache['Date']           = gmdate("D, d M Y H:i:s T", $date);
        $this->cache['Max-Age']        = $maxAge;
        $this->cache['Content-Type']   = $type;
        $this->cache['Url']            = $this->url;

        if ($lastModified) {
            $this->cache['Last-Modified'] = gmdate("D, d M Y H:i:s T", $lastModified);
        }

        // Save only if body is a valid image
        $body = $this->http->getBody();
        $img = imagecreatefromstring($body);

        if ($img !== false) {
            file_put_contents($this->fileName, $body);
            file_put_contents($this->fileJson, json_encode($this->cache));
            return $this->fileName;
        }

        return false;
    }
public function save ( ) { $ this -> cache = array ( ) ; $ date = $ this -> http -> getDate ( time ( ) ) ; $ maxAge = $ this -> http -> getMaxAge ( $ this -> defaultMaxAge ) ; $ lastModified = $ this -> http -> getLastModified ( ) ; $ type = $ this -> http -> getContentType ( ) ; $ this -> cache [ 'Date' ] = gmdate ( "D, d M Y H:i:s T" , $ date ) ; $ this -> cache [ 'Max-Age' ] = $ maxAge ; $ this -> cache [ 'Content-Type' ] = $ type ; $ this -> cache [ 'Url' ] = $ this -> url ; if ( $ lastModified ) { $ this -> cache [ 'Last-Modified' ] = gmdate ( "D, d M Y H:i:s T" , $ lastModified ) ; } // Save only if body is a valid image $ body = $ this -> http -> getBody ( ) ; $ img = imagecreatefromstring ( $ body ) ; if ( $ img !== false ) { file_put_contents ( $ this -> fileName , $ body ) ; file_put_contents ( $ this -> fileJson , json_encode ( $ this -> cache ) ) ; return $ this -> fileName ; } return false ; }
Save downloaded resource to cache.

@return string as path to saved file or false if not saved.
Save downloaded resource to cache .