Simone
Simone

Reputation: 85

Zend display image

Hi i'm using zend framework and what i want is to show an image. My image is in a folder /uploads/photo/default.jpg. If i move the folder to /public/... everithing works fine but I would prefere to leave there if i can because all images are profile's image so i don't want to leave them in public... My code to show the image is

<img id="image" src=<?php echo $this->baseUrl().'/uploads/foto/default.jpg'; ?> >

And I know that it don't work but there are a way to leave my folder there changing my code?

Upvotes: 0

Views: 922

Answers (1)

Tim Fountain
Tim Fountain

Reputation: 33148

The images need to be publicly accessible so a browser can view them. If you don't want to physically store them in the public folder you either need to make them accessible from there (by creating a symlink from public/uploads to your uploads folder), or serve them via. a PHP script, which would be able to read the data from wherever the file is located.

Serving binary data via. PHP has its own issues, as it will be slower and you'll need to ensure you send the appropriate headers. But this would allow you to restrict access, e.g. only allowing users to view their friends' profile images, if this is your goal.

Upvotes: 2

Related Questions