A simple file download using the header() function. We briefly explained the excel operation tutorial. Friends in need can refer to it.
The code is as follows
代码如下 |
复制代码 |
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:attachment;filename=test_data.xls");
|
|
Copy code
|
header("Content-type:application/vnd.ms-excel");
代码如下 |
复制代码 |
$filename = "20090210.xls";
$file = fopen(PUBLIC_EXPORT_DIR.$filename,"r"); // 打开文件
Header("Content-type:application/force-download");
Header("Accept-Ranges:bytes");
header("Content-Type: application/msexcel");
Header("Accept-Length:".filesize(PUBLIC_EXPORT_DIR.$filename));
Header("Content-Disposition:attachment;filename=".$filename);
echo fread($file,filesize(PUBLIC_EXPORT_DIR.$filename));
fclose($file);
|
header("Content-Disposition:attachment;filename=test_data.xls"); |
Example
The code is as follows
|
Copy code
|
$filename = "20090210.xls";
$file = fopen(PUBLIC_EXPORT_DIR.$filename,"r"); // Open file
Header("Content-type:application/force-download");
Header("Accept-Ranges:bytes");
header("Content-Type: application/msexcel");
Header("Accept-Length:".filesize(PUBLIC_EXPORT_DIR.$filename));
Header("Content-Disposition:attachment;filename=".$filename);
echo fread($file,filesize(PUBLIC_EXPORT_DIR.$filename));
fclose($file);
http://www.bkjia.com/PHPjc/631317.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631317.htmlTechArticleA simple file download using the header() function. We briefly explained the excel operation tutorial. There are Friends in need can refer to it. The code is as follows Copy the code header(Co...
|