Reputation: 33
I created a script to load an image from an URL using CURL. To test that the file is a JPG, I'm using ($info['content_type'] == 'image/jpeg'). It works on most of the urls, but some return a html type : e.g http://www.super-fond.fr/IMAGES_VOITURES/lexus/2005-Lexus-LF-A-Concept-R-1280x960.jpg Could anyone tell me why this URL is html ?
Thanks
Upvotes: 3
Views: 1579
Reputation: 3565
It is because you not set a user-agent in request headers and this host rejects request with specific user-agent.
See CURLOPT_USERAGENT
in curl_setopt()
on how to set the user-agent:
curl_setopt($c, CURLOPT_USERAGENT, 'Mozilla');
Upvotes: 4