Bonjour,
Le script php ci-desous me permet d'ouvrir un document word existant contenu dans un dossier.
Mais quand il ouvre le fichier word, voit des caractère assez-bizarre, autre que ceux qui figurent
sur mon fichier d'origine, mais les 2 documents (celui téléchargé et l'original figurant dans le repertoire
du serveur) portent le même nom.
Voici le code :
<?php
$path ="protocoles/";
$fullPath = $path.$_GET['download_file'].".doc";
echo $fullPath;
if ($fd = fopen ($fullPath, "r")) {
$fsize = filesize($fullPath);
$path_parts = pathinfo($fullPath);
$ext = strtolower($path_parts["extension"]);
switch ($ext) {
case "doc":
header("Content-type: application/msword");
header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\"");
break;
default;
header("Content-type: application/octet-stream");
header("Content-Disposition: filename=\"".$path_parts["basename"]."\"");
}
header("Content-length: $fsize");
header("Cache-control: private"); //use this to open files directly
while(!feof($fd)) {
$buffer = fread($fd, 1024);
echo $buffer;
}
}
fclose ($fd);
exit;
?>
Aidez-moi à corriger ce bugg