0

私はサイトを書いて維持しており、2 週間前の 3 月 11 日の月曜日... 2 回の IE 更新と夏時間が有効になった直後です。このコードは壊れていましたが、IE8 を実行している Windows XP マシンでのみ、かつ SSL 暗号化のみを使用していました。問題は、このファイルを安全に送信する必要があることです。繰り返しますが、このコードは XP マシンの firefox、または Windows 7 の IE 9 で動作します。

ファイルは要求に応じて作成され、すぐに削除されます

問題は断続的ではありません...一貫して失敗します..そして迅速に(基本的にすぐに...タイムアウトの問題などはありません)

ここにエラーがあります:http://i.imgur.com/j0cOJ0L.png

現在の PHP ファイルは次のとおりです。

//////////////////
// Download script
//////////////////

$path = $_SERVER['DOCUMENT_ROOT']."/mysite/"; // change the path to fit your websites document structure
$fullPath = $path.$B->LastName.$P->Property_ID.".fnm"; 
if ($fd = fopen ($fullPath, "r")) {
    $fsize = filesize($fullPath);
    $path_parts = pathinfo($fullPath);
    $ext = strtolower($path_parts["extension"]);
    switch ($ext) {
       case "fnm":
        header("Content-type: application/fnm"); // add here more headers for diff. extensions
       header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachment' to force a download
        break;
        default;
        header("Content-type: application/octet-stream");
        header("Content-Disposition: filename=\"".$path_parts["basename"]."\"");
    }
    header("Content-length: $fsize");
    header("Cache-control: private"); //use this to open files directly
    while(!feof($fd)) {
        $buffer = fread($fd, 2048);
        echo $buffer;
    }
}
fclose ($fd);

////////////////////////
//Delete the file from the server
/////////////////////////
$myFile = $path.$B->LastName.$P->Property_ID.".fnm"; 
unlink($myFile);

exit;
4

1 に答える 1

4

私がテストを実行したとき、必要なのはcache-control を Privateにして、 Pragma: privateヘッダーを追加するだけのようです
サンプルコード:

header('Content-Disposition: attachment; filename='.urlencode($zipFileName));
header('Content-Type: application/zip');
header('Content-Length: '.filesize($zipFileName) );
header("Cache-Control: private");
header("Pragma: private");
readfile($zipFileName);


httpsを介してIE8で魅力的に機能します。

于 2013-05-01T15:57:30.323 に答える