我写了并维护了一个网站,两周前的3月11日星期一......两次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;
答案 0 :(得分:4)
当我运行测试时,似乎只需将缓存控制设为私有,然后添加 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);
就像IE8的魅力一样,通过https。