On Jun 7, 12:14 am, "Samuel DeVore" <[EMAIL PROTECTED]> wrote:
> If you do the image in db first then you can do an easy optimization later
> and look really brilliant because it serves them so much faster ;)  On the
> other hand it is easier to control access to images when they are not just
> sitting where apache can toss them on any old image site it wants.

True, but controlling access !== putting the image binary data in the
db.

You can do it via apache, or put the files out of the webroot and
serve them up via a script.

Allen uploading an images is just a form, here's an example of serving
it up:

function serveImage($Gali=1,$Imagei=1) {
        $this->autoLayout = false;
        $Galleries = $this->_getGalleries($this->GalRoot);
        $Images = $this->_getPictures($Galleries[$Gali]);
        $Image = $Images[$Imagei];
      $Info = getimagesize( $this->GalRoot.$Galleries[$Gali].DS.
$Image );
        if ($Info[2] == 1) {
                $Type = 'gif' ;
        } elseif ($Info[2] == 2) {
                $Type = 'jpeg' ;
        } elseif ($Info[2] == 3) {
                $Type = 'png' ;
        } else {
                header( 'HTTP/1.0 404 Not Found' );
                die ;
        }
        header( "Content-type: image/$Type" );
        @readfile( $this->GalRoot.$Galleries[$Gali].DS.$Image );
        die();
}

It's not ground breaking, but then I did write it about a year ago.
Minor clarification: This was with a flat folder structure (no
subfolders) and the _get* methods simply listed the folders/files in a
dir. Adapt however you wish :)

hth,

AD


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to