I have a WordPress site where we are facing some issues using images.
The images exist on the server, when we access the images via URL, it works and the image shows.
But when we use curl, file_get_contents, fopen, copy etc command to get or access the file, we get the 404 error status code.
Can anyone can help me, I don't know if it's a server issue or WordPress issue.
Below is my sample of code:
$url = "http://blogbucket.in/wp-content/uploads/files/0B6IGyYw9A5RYS0tNelJrdmFsMTQ/airbitz-co1.png";
$ch = @curl_init($url);
@curl_setopt($ch, CURLOPT_HEADER, true);
@curl_setopt($ch, CURLOPT_NOBODY, true);
@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
@curl_setopt($ch, CURLOPT_FAILONERROR, true);
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
@curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
@curl_exec($ch);
$header = curl_getinfo($ch);
curl_close($ch);
echo "<pre>";
print_r($header);
echo "<pre>";
Below are the links I've looked at so far.
cURL is returning 404 on a file that exists (remote server). Why?
How to check if an URL exists with the shell and probably curl?
PHP Detecting if source image url link leads to a "broken" image?
You can try it here.