mettre un en-tête de la façon suivante:tête Content-Length toujours zéro
header('Content-Length: ' . filesize($strPath));
Sur mon PC avec ZendServer il fonctionne très bien et je peux télécharger un fichier avec la taille de fichier correct. Sur le serveur de production, un Solaris avec Apache et PHP compilé, j'obtiens un fichier avec la taille du fichier égale à zéro, donc un fichier vide.
Existe-t-il un paramètre de configuration? Quelque chose qui peut empêcher de définir 'Content-Length: 1222'?
Merci.
Le code:
<?php
error_reporting (E_ALL); ini_set ('display_errors', '1');
require 'includes/prepend.inc.php';
require __ADMIN_DIR__.'/AdminInfo.php';
$intFile = QApplication::QueryString('fileID');
if($intFile == '') die('Error: missing ID');
$objFile = File::Load($intFile);
$blnRight = false;
$objAdminInfo = new AdminInfo();
if($objAdminInfo->isAdmin()) {
$blnRight = true;
}
else {
$objSecMan = new SecurityManager(
'file:'.$objFile->FileID,
$objAdminInfo->getUserID()
);
$blnRight = $objSecMan->processResource('view');
}
// if the user can modify and or publish, can even view the file
if(!$blnRight) {
$blnRight = $objSecMan->processResource('modify');
if(!$blnRight) {
$blnRight = $objSecMan->processResource('publish');
}
}
//$strPath = __UPLOADS__.DIRECTORY_SEPARATOR.$objFile->FileID;
$strPath = 'subdept.csv';
if (file_exists($strPath) && $blnRight) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$strPath);//$objFile->Filename);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($strPath));
ob_clean();
flush();
readfile($strPath);
exit;
}
else {
die('Restricted access');
}
?>
Quand je commente le code avant $ strPath cela fonctionne, il doit donc être quelque chose dans le cadre sanglant. Je voudrais jeter tout le CMS loin. Etes-vous sûr que le fichier existe sur le serveur de production?
Merci! Je reçois: Transfer-Encoding: chunked et pas de 'Content-Length' Je devrais trouver un moyen d'arrêter le serveur pour faire cela. – rtacconi
Peut-être, bien que n'étant pas sûr, le framework Zend détermine s'il faut utiliser l'encodage en segments ou non. Besoin de vérifier la documentation – Ram
ok, merci beaucoup – rtacconi