J'ai une fonction pour produire des documents, images, etc:header() dans IE
public function direct($theMimeType, $thePath)
{
header('Content-type: '.$theMimeType);
ob_clean(); // clean output buffer
flush(); // flush output buffer
readfile($thePath);
exit;
}
Il fonctionne très bien dans Firefox. Le fichier s'ouvre s'il s'agit de PDF, DOCX ou de tout autre fichier. Cependant, dans IE il se fige et rien ne se montre.
Ce qui pourrait causer cela?
EDIT:
J'ai ajouté quelques autres en-têtes:
public function direct($theMimeType, $thePath)
{
$aSize = filesize($thePath);
$aBegin = 0;
$aEnd = $aSize;
$aFilename = end(explode('/', $thePath));
$aTime = date('r', filemtime($thePath));
$aContentDisposition = ('application/pdf' === $theMimeType) ? 'inline' : 'atachment';
header('HTTP/1.0 200 OK');
header("Content-Type: $theMimeType");
header('Cache-Control: public, must-revalidate, max-age=0');
header('Pragma: no-cache');
header('Accept-Ranges: bytes');
header('Content-Length:'.($aEnd-$aBegin));
header("Content-Range: bytes $aBegin-$aEnd/$aSize");
header("Content-Disposition: $aContentDisposition; filename=$aFilename");
header("Content-Transfer-Encoding: binary\n");
header("Last-Modified: $aTime");
header('Connection: close');
ob_clean(); // clean output buffer
flush(); // flush output buffer
readfile($thePath);
exit;
}
Eh bien, cela fonctionne dans IE maintenant, mais encore il ouvre le fichier beaucoup plus lent que Firefox. Il semble y avoir quelques secondes geler avant que le navigateur IE ouvre le fichier.
Nous avons besoin d'un peu plus d'informations que celles-ci, telles que "Quels autres en-têtes envoyez-vous?" –
Il n'y a pas d'autres en-têtes. J'utilise simplement Content-type. –
@ Baker Baker: Vérifiez ma question mise à jour. J'ai ajouté quelques autres en-têtes. –