I am using the readfile function to read image files. It works in most cases except when an image is located in a directory with htaccess file.
Here is an example:
header("Content-type: image/jpeg");
ob_clean(); // clean output buffer
flush(); // flush output buffer
readfile("http://127.0.0.1/WebProjects/project1/data/media/images/original/7.jpg");
exit;
The htaccess is located in the http://127.0.0.1/WebProjects/project1/ directory and looks like this:
RewriteEngine On
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ /public/index.php [NC,L]
Any way how to get around this? The htaccess file must be there because the web application in that folder needs it to work.
Why not read the file directly from the filesystem instead of going through the web server?