Bonjour,

Le téléchargement de fichiers .doc ne marche pas. J'arrive bien à l'enregistrer mais au moment de l'ouvrir il me demande l'encodage... J'ai essayé plusieurs encodage (utf8, iso... ), rien à faire.

Voici mon code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 
if ( $don['type'] == "pdf") $type = "application/pdf";
else if ( $don['type'] == "doc") $type = "application/msword";
else if ( $don['type'] == "xls") $type = "application/vnd.ms-excel";
else $type = "application/octet-stream";
 
$dossier = "../../".$don['dossier']."/";
$file = $dossier.$don['nom_fichier'];
$size = filesize($file);
$name = $don['nom_fichier'];
 
header("Content-disposition: attachment; filename=$name"); 
header("Content-Type: application/force-download"); 
header("Content-Transfer-Encoding: $type\n"); // Surtout ne pas enlever le \n
header("Content-Length: ".$size); 
header("Pragma: no-cache"); 
header("Cache-Control: must-revalidate, post-check=0, pre-check=0, public"); 
header("Expires: 0"); 
readfile($file);
Merci de votre aide

PS : Le téléchargement de pdf marche très bien?