CodeIgniter Forums
Pictures outside of the public_html directory - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Pictures outside of the public_html directory (/showthread.php?tid=30063)



Pictures outside of the public_html directory - El Forum - 05-01-2010

[eluser]Unknown[/eluser]
How can I view the pictures in the CI outside the public_html directory
- galleries
- public_html

I write "../galleries/photo.jpg" and does not work.


Pictures outside of the public_html directory - El Forum - 05-01-2010

[eluser]Jelmer[/eluser]
Files outside the webroot can't be accessed through normal means, which is most often the reason to put things outside the webroot. If you want your images to be easily accessible you should put them in the public_html folder.

I've put documents outside the webroot to be able to secure them and only make them accessible when a user was logged in. Use readfile() for such purposes but don't forget to set the MIME type headers before you use the readfile function. Like this:
Code:
header('Content-Type: image/jpg');
readfile('../galleries/photo.jpg');



Pictures outside of the public_html directory - El Forum - 05-01-2010

[eluser]Unknown[/eluser]
Thanks!
Now it works well.