大家知道,如果要用webbrowser打开.诸如.xls,.doc等文件时必须修改http header,
Content-type:application/vnd.ms-excel(http header)
Content-Disposition:"attachment; filename=fileName" (MIME扩展协议)现在我想让IE读取server上的xls文件,并且在Client上显示.我的代码是:<?php
header( "Content-type:application/vnd.ms-excel ");
header( "Content-Disposition:filename=test.xls ");
?>我的test.xls文件是:
Content-type:application/vnd.ms-excel(http header)
Content-Disposition:"attachment; filename=fileName" (MIME扩展协议)现在我想让IE读取server上的xls文件,并且在Client上显示.我的代码是:<?php
header( "Content-type:application/vnd.ms-excel ");
header( "Content-Disposition:filename=test.xls ");
?>我的test.xls文件是:
$filename=$_GET["conditionArr"];//传一个文件
if (!file_exists($filename)) {
echo $filename;
error_log("Error: file " . $file_path . " not found!", 0);
exit;
}
$filesize=filesize($filename);
$fp = fopen($filename, 'rb');
header("Content-Type:text/plain");
header("Accept-Ranges:bytes");
header("Accept-Length:".filesize($filename));
header("Content-Disposition:attachment;filename=".basename($filename));
flock($fp, 2);
$attachment = @fread($fp, $filesize);
echo $attachment;
fclose($fp);
?>