ravi
ravi

Reputation: 277

Image Display in PHP

I want to display image through PHP. When I put image in /var/www/ directory then it is working fine, I am giving full path.

But when I put image in some other directory (say home) then it is not displaying.

Upvotes: 0

Views: 82

Answers (2)

Jonnix
Jonnix

Reputation: 4187

First off, you should really check your error logs as they will probably point you in the right direction.

Without more information, I'd have an educated guess that the Apache user does not have rights to the file and/or the containing directories.

You can change permissions using the chown and chmod commands in a shell.

EDIT: But don't allow access to any dir with sensitive data (e.g. your home directory) to the webserver!

Upvotes: 1

Javier Soto
Javier Soto

Reputation: 4870

Usually, servers have some kind of sandbox which prevent your code to access files outside of it for security reasons. I encourage you to put all data you want your server to be able to access inside its folders (/var/www directory or subdirectories of it)

Upvotes: 1

Related Questions