This bit of code reads from an RSS feed and shoulfd detect if an image exisists on the server or not:
<?php
$feedURL = 'http://www.goapr.com/news/category/product-release/feed/';
$sxml = @simplexml_load_file($feedURL);
if($sxml){
$i=0;
foreach($sxml->channel as $channel){
foreach($channel->item as $item){
//if($i==6){break;}
if($item->prodimg=="~"){break;}
if($item->prodpage=="~"){break;}
$i += 1;
$file = 'http://www.goapr.co.uk'. $item->prodimg;
if (file_exists($file)) {
echo "The file $file exists";
} else {
echo "The file $file does not exist";
}
}
}
}else{
echo 'Sorry there was an error. The recent products will return shortly.';
}
?>
Many of the images do exist, but it returns all images not found:
The file http://www.goapr.co.uk/includes/img/newprod/ultras4.png does not existThe file http://www.goapr.co.uk/includes/img/newprod/30tpulleys.png does not existThe file http://www.goapr.co.uk/includes/img/newprod/tiguan.png does not existThe file http://www.goapr.co.uk/includes/img/newprod/2325row.png does not existThe file http://www.goapr.co.uk/includes/img/newprod/plus.png does not existThe file http://www.goapr.co.uk/includes/img/newprod/2017r.png does not existThe file http://www.goapr.co.uk/includes/img/newprod/v24gti.png does not existThe file http://www.goapr.co.uk/includes/img/newprod/q5gen3.png does not existThe file http://www.goapr.co.uk/includes/img/newprod/s8downpipes.png does not existThe file http://www.goapr.co.uk/products/ All images are detected as not found.
Its not the same as: How to check if a file exists from a url as the files are on the same filesystem as this PHP page.