How can I solve the problem that php exports and downloads Excel files are blocked by IE? Neither can I use stream output.

Source: Internet
Author: User
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 --------------------

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.