
Originally Posted by
cat250
PHP Code:
if*(file_exists($image['Poster']))*{
**echo*"a".$image['Poster']."";
}*else*{
**echo*"b".$json['Poster']."";*}*
You should actually be getting a parse error. Are the asterisks ( * ) actually in your PHP script?
Assuming you have this script:
PHP Code:
if(file_exists( $image['Poster'] )){
echo "a".$image['Poster']."";
}else{
echo "b".$json['Poster']."";
}
then your script does appear to be working, even though it's not the result you expected/want.
1. file_exists() can work with URLs in some cases, but most servers do not enable/allow this by default. That's probably why your if() statement is failing.
filesystem functions are intended for, and are much more reliable with, file paths on your own server.
2. IMDB blocks direct requests on its media server - likely an attempt to reduce hotlinking:

Originally Posted by
ia.media-imdb.com/images/M/MV5BMTYwNTE3NDYzOV5BMl5BanBnXkFtZTcwNTU5MzY0MQ@@._V1_SX320.jpg
Referral Denied
You don't have permission to access "http://ia.media-imdb.com/images/M/MV5BMTYwNTE3NDYzOV5BMl5BanBnXkFtZTcwNTU5MzY0MQ@@._V1_SX320.jpg" on this server.
so, your attempt to check if the image exists probably wouldn't be successful anyway. Which brings us to...
3. What are you trying to accomplish with echo "a".$image['Poster']? Are you trying to display the image? As you see with your own code, this will only print the contents of $image['Poster'] (i.e., the URL).
If you want to display an image (one that you aren't denied access to), you need to print an <img> tag with the appropriate source URL.
Alternatively, you could read the image file (one on your own server, or one you have access to) and print the file's contents, along with the appropriate content-type headers. But that's more complicated, usually unnecessary, and probably not what you're trying to do.
----------------------------------------
In any case, can you explain more about what you're trying to accomplish? What do you want the end result to be?
Bookmarks