Downloads: Fehler bei Internet Explorer

Hallo,
ich generiere per PHP dynamische Downloads:

header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"".$fileName."\"");
header('Content-Length: '.filesize ($file));
header('Pragma: no-cache');
header('Expires: 0');
echo $buffer;

Sobald der Download nun unter IE geöffnet wird erscheint wie gewohnt das Fenster zum direkten Öffnen oder Speichern.
Ist der Download nun zum Beispiel ein PDF-Dokument, kann ich es abspeichern und später ganz normal und ohne Fehler ansehen. Öffne ich den Download (in diesem Fall das PDF) nun direkt, dann öffnet sich zwar der Adobe Reader, bricht aber dann mit folgender Fehlermeldung ab:
Datei existiert nicht

Wie gesagt „Speichern unter…“ geht, nur das direkte „Öffnen“ funkt nicht. Hat jemand ne Erklärung?

gruß Markus

hi,

http://de3.php.net/manual/de/function.header.php

da steht auch ein workaround zu dem problem.
hier ein auszug:

anfang

I have a download script that uses HTTP headers to download files that are located outside of the web path (on a Linux web server).

I was doing what was posted in the normal examples:

$SRC_FILE = „/path/outside/web/server/test.txt“;
$download_size = filesize($SRC_FILE);
$filename = basename($SRC_FILE);
header(„Content-Type: application/octet-stream“);
header(„Content-Disposition: attachment; filename=$filename“);
header(„Accept-Ranges: bytes“);
header(„Content-Length: $download_size“);
@readfile($SRC_FILE);

But in Internet Explorer, whenever I would click the link to downlad, I could only save the file. If I tried opening the file directly, it gave an error about not being able to find the temporary file.

After digging around for a while, I found the solution. You have to set the Cache-Control to private. So I added the following headers (on top/before the others):

header(„Pragma: public“);
header(„Expires: 0“);
header(„Cache-Control: private“);

And now it works. I had a different Cache-Control setting before, and it wasn’t working. So I’m certain that setting the Cache-Control to private is what fixed it.

The server environment is Apache 1.3.29 with PHP 4.3.8 running over mod_ssl and using PHP sessions.

Hope this helps someone!

ende

aber am besten du liest selber mal nach, bei obigem link.

gruss - josh -

Danke so gehts! (owT)

[Bei dieser Antwort wurde das Vollzitat nachträglich automatisiert entfernt]

kP Markus,

der satz hoert sich irgendwie merkwuerdig an:

Student - arbeite aber mehr als ich eigentlich studieren sollte ;- )

ich glaube das liegt daran, das dieser satz eigentlich angewendet wird in folgender form:

arbeite mehr als ich sollte.

interpretiert man deinen satz, wuerde ich sagen, das du sehr viel studierst.

war das so gemeint? ;o)

gruss

  • josh -