Php exports and downloads Excel files are blocked by IE. how can this problem be solved? Neither can I use stream output! How can I solve the problem of preventing IE from downloading Excel files? & Nbsp; When you click the export button, you can use AJAX to generate an excel file in the background. to directly display the file storage dialog box on the page, whether it is through js window. how can I solve the problem of IE blocking the Excel file exported and downloaded by locatphp? Neither can I use stream output!
How can I solve the problem of preventing IE from downloading Excel files?
When you click the export button, AJAX is used to generate an excel file in the background, and you want to directly display the file storage dialog box on the page,
Neither the window. location. href = ''through js, nor the new page submitted through form, nor the output through stream in the background are blocked by IE;
Who can solve this problem?
PHP code
$file_name="test.xls";
$file_path="../data/down/2011/03/21/";
$file_name = urldecode($file_name);
// ../ is not allowed in the file name
if (!ereg("(\.\.\/)", $file_name))
{
// Does the file exist?
if (file_exists($file_path . $file_name))
{
$fp = @fopen( $file_path . $file_name, "r" );
//Prompt the user to download the new torrent file.
header("Expires: 0" );
header("Pragma:public" );
header("Cache-Control:must-revalidate,post-check=0,pre-check=0" );
header("Cache-Control:public");
header("Content-Type:application/octet-stream" );
if (strstr($_SERVER["HTTP_USER_AGENT"],"MSIE")){
header("Content-Disposition:attachment;filename=".urlencode($file_name) );
}else{
header("Content-Disposition:attachment;filename=".$file_name );
}
header("Content-transfer-encoding: binary");
header("Content-length:".@filesize( $file_path . $file_name ));
@fpassthru( $fp );
@fclose( $fp );
}
exit();
}
------ Solution --------------------
Then I just split it. haha.
------ Solution --------------------