I store user images in “images” forlder and the full path is something like this:
When I try to get the image path like this:
$path = 'images/imagename.jpg';
it works fine on home page, but since I have different permalink structure it doesn’t work on other pages. It becames something like http://example.com/something/images/imagename.jpg
Of course I can write:
$path = 'http://example.com/images/imagename.jpg';
but in this case
file_exists($path)
always returns false even if the file exists. It’s a problem!
Can anyone please help?
Try
$path = '/images/imagename.jpg;that way you’re are referencing from the document root path.