HTTP-Header: PHP, Download, IE + https
(Kommentare: 3)
Problem: Ich habe eine Web-Applikation, z.B. PHP-Skript, und möchte ein Microsoft-Office-Dokument zum Download anbieten, das Ganze ggf. via https. Ohne weiteres kann man aber mit dem Internet Explorer 7 (MSIE 7) kein Office-Dokument (mit https/SSL) runterladen.
Siehe: Microsoft Support-Hinweis.
Mögliche Fehlermeldungen:
Error message 1
Internet Explorer cannot download file from server.
Internet Explorer was not able to open this Internet site. The
requested site is either unavailable or cannot be found. Please try
again later.
Error message 2
The page cannot be displayed.
The page you are looking for is currently unavailable. The Web site
might be experiencing technical difficulties, or you may need to adjust
your browser settings.
Cannot find server or DNS Error
Error message 3
Office Application Name cannot open the file.
Error message 4
Publisher cannot find the file you specified.
The problem occurs if the server is using Secure Sockets Layer (SSL)
and has added one or both of the following HTTP headers to the response
message:
Pragma: no-cache
Cache-control: no-cache,max-age=0,must-revalidate
Web sites that want to allow this type of operation should remove the no-cache header or headers.
Lösung am Beispiel eines PHP-Skripts, das eine RTF-Datei zum Download anbietet:
$filename = 'example.rtf';
$content = '...';
header("Content-type: application/rtf");
header("Content-length: " . strlen($content));
header("Content-Disposition: attachment; filename=" . $filename);
header("Cache-control: "); // For IE + https
header("Pragma: "); // or: header('Pragma: public'); // For IE + https
print $content;
Kommentare
Kommentar von Tim |
Kommentar von ptb |
tausend dank!
Kommentar von Dennis |
Was Tim sagt ist fast 10 Jahre später immer noch wahr. Danke!
Einen Kommentar schreiben