GetDotted Domains

Viewing Thread:
"PHP: file_exists() with images"

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Mon 17/07/06 at 01:41
Regular
"Peace Respect Punk"
Posts: 8,069
Hey, so I'm having some trouble with the file_exists() function... Basically I have some images and text files in a folder.

I want to check particular text files and images exist during the PHP script, and it'll work fine for the .txt files, but the images (which are .jpg files) don't...

They have the same file permissions as the .txt files (though I'm sure permissions don't matter anyway, as file_exists() just checks the file actually exists, not whether you can read it...), are in the same folder, and are definitely there, as I can display them using tags in the HTML, so they're definitely uploaded successfully...

It's just that file_exists() doesn't seem to like them or recognise that they are in fact there...

Any suggestions?
Cheers!


[EDIT] - Gah, make a topic, then immediately fix it! Not sure what was wrong though, but noticed the file_exists() for the .txt files had a relative path (ie. no leading '/'), while the one for the .jpg files was an absolute path, starting from my public_html... Made the .jpg one relative too and it worked fine... Not sure why that is but it's working now so all is well...
Mon 17/07/06 at 01:41
Regular
"Peace Respect Punk"
Posts: 8,069
Hey, so I'm having some trouble with the file_exists() function... Basically I have some images and text files in a folder.

I want to check particular text files and images exist during the PHP script, and it'll work fine for the .txt files, but the images (which are .jpg files) don't...

They have the same file permissions as the .txt files (though I'm sure permissions don't matter anyway, as file_exists() just checks the file actually exists, not whether you can read it...), are in the same folder, and are definitely there, as I can display them using tags in the HTML, so they're definitely uploaded successfully...

It's just that file_exists() doesn't seem to like them or recognise that they are in fact there...

Any suggestions?
Cheers!


[EDIT] - Gah, make a topic, then immediately fix it! Not sure what was wrong though, but noticed the file_exists() for the .txt files had a relative path (ie. no leading '/'), while the one for the .jpg files was an absolute path, starting from my public_html... Made the .jpg one relative too and it worked fine... Not sure why that is but it's working now so all is well...
Tue 26/09/06 at 16:26
Regular
"!"
Posts: 11
Old post, I know, but it's because the absolute path will be absolute to the server, that is, the root of the filesystem. If you want to use absolute paths, it's probably prefixed with something like /home/yourusername/public_html/ - 'though I don't know for Freeola.

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Thank you very much for your help!
Top service for free - excellent - thank you very much for your help.
Many thanks!
You were 100% right - great support!

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre
Feedback Close Feedback

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.