je veux obtenir l'en-tête du fichier. mais CURL renvoie une valeur différente avec get_headers.CURL obtenir en-tête retour différent avec get_headers
Je ne sais pas pourquoi. est ici résultat:
avec get_headers
Array
(
[0] => HTTP/1.0 200 OK
[1] => Content-Type: image/jpeg
[2] => Last-Modified: Wed, 14 Nov 2012 11:06:07 GMT
[3] => X-Cache-Status: HIT
[4] => Expires: Tue, 19 Jan 2038 03:14:07 GMT
[5] => Cache-Control: max-age=2592000
[6] => X-Cache: HIT
[7] => Content-Length: 120185
[8] => Connection: close
[9] => Date: Fri, 16 Nov 2012 08:01:15 GMT
[10] => Server: lighttpd/1.4.26
)
et cURL pas Content-Type ~> thats ce que je veux
Array
(
[0] => HTTP/1.1 200 OK
[1] => Content-Length: 120185
[2] => Connection: close
[3] => Date: Fri, 16 Nov 2012 08:01:42 GMT
[4] => Server: lighttpd/1.4.26
[5] =>
[6] =>
)
voici mon en-tête get par fonction boucle
function get_headers_curl($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$r = curl_exec($ch);
$r = split("\n", $r);
return $r;
}
CURL avec retour Content-Type si je mets
curl_setopt($ch,CURLOPT_HTTPGET,true);
mais il renverra également le contenu du fichier (corps), comment obtenir exactement le type de fichier CONTENU SEULEMENT avec CURL et sans contenu de fichier? Get_headers reçoit des informations pour une image, mais l'autre ne l'est pas.
Quelle version de PHP? – Baba
@Baba Bonjour, ma version PHP est 5.3 – TomSawyer
Est-il possible de fournir l'URL de l'image pour les tests ??? Pas capable de répliquer votre problème même sur PHP 5.3 – Baba