UPDATE: this problem was solved, my issue was a typo. The concept of what I was doing was correct.
I have a check if an image exits when I first display my page. It prints out:
if (@file_get_contents($url) != false)
{
// show URL
}
else {
// Show Placeholder Image
}
This code works, when I have my page first load and the php is written with the HTML.
BUT on other occasions, when I do a jQuery .post
or .get
call (so basically ajax) doing the file check above ALWAYS fails. I have printed out the URL and it points to correct file (I can do this by unsupprressing the errors). Now, the url is a different domain then the original file that is being called, so not sure if it is a cross domain issue (it is also a website that belongs to me so I have full access to the files).
Is this code not working due to ajax? Cross Domain? something else?
Also, I have tried file_exists
, getimagesize
and cUrl
as well to no avail.
EDIT:
Here is my message when errors are not suppressed:
Warning:
file_get_contents(http://www.---.---)
[function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in --- on line 352