I'm trying to check if a file does exist on a server or not, the script works fine in regards to testing the domain but not the file, I know for sure the file does not exist and still I'm getting 200 as if does exist. Can someone help me please find whats wrong?
Thank you,
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/test.gif");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
$headers = curl_exec($ch);
$info = curl_getinfo($ch);
foreach($info as $header => $value) {
echo "<p>$header: $value</p>\n";
}
echo "<pre>$headers</pre>\n";
?>