You are here

8 July 2011

This snippet gets content type of a file form external url. This snippet uses curl to download the file and get the content type.

Source code viewer
  1. $content_type = '';
  2. $ch = curl_init($feed_url);
  3. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  4. $content = curl_exec($ch);
  5. if(!curl_errno($ch))
  6. {
  7. $content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
  8. }
Programming Language: PHP