Rahul R
Rahul R

Reputation: 207

Identify file header using php

I want to find the file type hosted in external server.I tried get_headers() function but it returns an array of headers i need the content type only.The array is in different order according to the file so it can't be identified using position of array element.Please give me a solution.

Upvotes: 0

Views: 66

Answers (1)

If you set the format parameter to 1, it'll make an associative array of the headers:

$headers = get_headers($url, 1);
$content_type = $headers['Content-Type'];

See the documentation of get_headers for more information.

Upvotes: 6

Related Questions