In this project, I am uploading admin submitted files to a folder which is outside of the public folder.
/web/ (the public folder)
/upload/ (uploading image to t
direct
path won't work because you can't get content from outside of root folder.. you can do it another way, Read image file in php script from server dir path and serve file using header
script file.php
<?php
$mime_type = mime_content_type("/image_path/{$_GET['file']}");
header('Content-Type: '.$mime_type);
readfile("/image_path/{$_GET['file']}");
?>
<img src="file.php?file=photo.jpg" />
You normally do not access directories outside web root.
A quick solution is to add a alias
in apache config like
alias /upload/ /www/userid/upload/
inside the virtualhosts
and use
/upload/photo.jpg
I would skip the php and folder options and use symbolic links directly in the server. I assume that you are using some form of linux as your server. So, if it is not a security issue, simply make the upload folder a copy of the public folder that you have the images in. This, will, however, make everything in that folder appear in the upload folder, but this should not be much of an issue, as the alternative would be to alter permissions on the upload folder and script the whole thing out that way.