telecharge fichier .zip

Par Romane Pm, il y a 6 ans


Bonjour à tous,

Je rencontre un problème:

Je voudrais télécharger un fichier .zip que je récupère d'un API. Pour cela voici le code que j'utilise:

$curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => "URL", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( rtrim($token, "\r\n") ), )); $response = curl_exec($curl); $fichierZipPhotos=json_decode(curl_exec($curl), true); $name=$numeroAffaire.'_'.$origine.'_'.$numeroNC.'_'.$titre; header('Cache-Control: public'); header('Content-type: application/zip'); header('Content-Disposition: attachment; filename='.$name.'.zip'); curl_close($curl); echo $response;

Cependant, cela me télécharge un fichier (avec le bon nom) en .html. Je ne comprends pas pourquoi. Comment avoir le fichier en .zip ?

Merci

Aucune réponse