We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Private folder files can't access from the view

Hi,

I seen this thread and I'm doing somethink like this. I have put the public files folder inside apps/common/files/img because I don't want than my images are visible from URL that is why I put all my images inside phalcon and not in the public folder.

I can't get my images from te controller but I can't display theses images in my view because I have a 404 error.

How can I access to my private files folder from the view to display them ?

Thanks.



9.3k
Accepted
answer
edited Apr '16

If you have in your template something like this

<img src="apps/common/files/img/...">

then it will not work, because client browser and your webserver cant access private image file. If you want to make it work, you have to serve these images by PHP. Make new route for private images, create new controller and action, which will serve private media for your client.

Thanks David. This is a good idea I'll do that.