Page 1 sur 1

probleme avec mon de telechargement

Posté : 16 déc. 2013, 16:46
par greg6fr
Bonsoir,
Lorsque je downloade mes fichiers en .xlsx avec ce code php, au moment d'ouvrir le fichier telecharge, il y a une erreur qui apparait
voici le code de telechargement ;

Code : Tout sélectionner

<?php $urlf = 'files/'; if(file_exists($urlf)) { header('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); // application/vnd.openxmlformats-officedocument.SpreadsheetML.Sheet header('Content-Disposition: attachment; filename="LR05WS010-ONFE1.xlsx"'); readfile($urlf); } ?>

Re: probleme avec mon de telechargement

Posté : 16 déc. 2013, 17:04
par mateo2996
Salut !
Essaye avec cette commande :
$fileName = "C:\TonFichier"; modifie et met la source de ton fichier.
header('Content-disposition: attachment; filename='.$fileName); 
header('Content-Type: application/force-download'); 
header("Content-Transfer-Encoding: binary"); 
header("Content-Length: ".filesize($fileName));
header("Pragma: no-cache");
header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
header("Expires: 0");
readfile($fileName);
Ciao

Matéo

Re: probleme avec mon de telechargement

Posté : 16 déc. 2013, 17:07
par Mazarini
Il faut envoyer un fichier xlsx, pas un répertoire : $urlf = 'files/';

Re: probleme avec mon de telechargement

Posté : 16 déc. 2013, 17:48
par greg6fr
Merci mateo2996,
Ton code marche tres bien.
Merci

Re: probleme avec mon de telechargement

Posté : 16 déc. 2013, 17:49
par mateo2996
Aucun soucis !
Au plaisir,

Matéo