0

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?

1
  • have you checked file permissions? chmod o+r Commented Feb 24, 2011 at 11:40

4 Answers 4

3

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;
Sign up to request clarification or add additional context in comments.

Comments

1
'$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

Comments

0

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

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.