Monday, July 26, 2010

Re: Display images outside webroot folder

When the images are uploaded do you save any information into your db
that associates to the filename on disk?

If you do you could use that model's controller and an action like
getimage and then use the media helper to return the file.

as in myapp/users/getimage/somename

This can further be enhance with named parameters to match to a
specific user
myapp/users/getimage/uid:20/fname:somename

Media View allows you to return binary data from a controller action
with a specific header that identifies its type. The controller and
model have access to the folders outside the browsers view and can
read the file and return it as a specific image.
http://book.cakephp.org/view/489/Media-Views

I use this technique to track when emails have been read. One of the
space.gif images in my emails has unique named parameter which ties it
directly to a specific sent email. So when it is read the controller
action updates the sent email as read and the gif that is returned is
a file in my templates folder.

On Jul 26, 5:15 pm, cricket <zijn.digi...@gmail.com> wrote:
> On Mon, Jul 26, 2010 at 7:56 AM, rez...@gmail.com <rez...@gmail.com> wrote:
> > thanx
>
> > the project files structure
> > /
> > /webroot
> > /userFiles
> > /controllers
> > /models
> > /vendors
> > ..
> > ..
> > etc
>
> > is userFiles folder outside document root ?
>
> Yes, the "root" of your site is the webroot dir (hence the name).
> Anything in there can be accessed directly (like, /css/whatever.css,
> /img/whatever.jpg, or /foo.html).
>
> > whats can I do to make a separated image folder for users ?
>
> There are three (that I know of) ways to go about this using existing
> code. MediaView [1], Nick Baker's FileUpload plugin [2], or David
> Persson's Media plugin [2]. I haven't used the latter, although I have
> looked at the code. It seems very complete but, as I said, I haven't
> used it. The FileUpload plugin works great, although I've never used
> the helper part of it.  I don't know if it's a very good solution if
> you'll be serving lots of these files. If so, you should consider
> caching. Ditto for MediaView.
>
> [1]http://book.cakephp.org/view/489/Media-Views
> [2]http://github.com/webtechnick/CakePHP-FileUpload-Pluginhttp://bakery.cakephp.org/articles/view/file-upload-component-w-autom...
> [3]http://wiki.github.com/davidpersson/media/

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: