Reputation: 1520
HI, i have an image .jpg into my server. If I link direct to image i have this error:
Forbidden You don't have permission to access http://...
I need to show with php. I have try
header('Content-Type: image/jpeg');
readfile('$file');
But nothing... I have also try using server root... any suggestions?
Upvotes: 0
Views: 1799
Reputation: 8040
Probably the file is in a directory that the web server isn't set up to allow access to. PHP can access pretty much any directory on the web server, but apache/IIS/etc will restrict normal access by default to only directories specified in their configuration. If this is the problem then serverfault may have better expertise to help you get your server set up.
Upvotes: 0
Reputation: 212412
'$file'
in single quotes is looking for a file called $file
"$file"
in double quotes or even without any quotes at all, is looking for a file called by the value stored in $file
Upvotes: 1
Reputation: 146390
You are trying to load a file called $file
. That's a weird name for a picture; I assume it's a PHP variable name where you store the picture file name. In such case:
header('Content-Type: image/jpeg');
readfile($file);
exit;
Upvotes: 3
Reputation: 1671
You have to set the correct rights for the image. You can do this via ssh (console) or easier with your ftp program. If done so, you can access it directly
Upvotes: 0