Here’s a function that can get the mime type of a remote file. It will also follow any redirects that are in place.
function get_url_mime_type($url) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_NOBODY, 1); curl_exec($ch); return curl_getinfo($ch, CURLINFO_CONTENT_TYPE); }