Solve the problem that php cannot be opened when downloading excel files
- /**
- * Php code for excel file download
- * Edit: bbs.it-home.org
- */
- If (file_exists (CACHE_PATH. $ file_name )){
- // $ This-> logger-> error ('file realpath: '. realpath (CACHE_PATH. $ file_name ));
- Header ('pragma: public ');
- Header ('expires: 0 ');
- Header ('content-Encoding: none ');
- Header ('cache-Control: must-revalidate, post-check = 0, pre-check = 0 ');
- Header ('cache-Control: public ');
- Header ('content-Type: application/vnd. ms-excel ');
- Header ('content-Description: File Transfer ');
- Header ('content-Disposition: attachment; filename = '. $ file_name );
- Header ('content-Transfer-Encoding: binary ');
- Header ('content-Length: '. filesize (CACHE_PATH. $ file_name ));
- Readfile (CACHE_PATH. $ file_name );
- } Else {
- $ This-> logger-> error ('export model: '. $ id.' error: file not produced ');
- Echo 'script alert (\ 'export error, file not exists! \ ') Script';
- }
>>> Articles you may be interested in: examples of using PHPExcel to identify and format the date format in Excel: phpExcel Chinese help Manual (Knowledge Point) phpexcel quick Development Guide (good) phpexcel database import code phpexcel data export instance code phpexcel class library instance support (excel2003 excel2007) examples of PHPExcel reading excel files phpexcel exporting the use of the phpExcel class of a classic excel instance share PHPExcel common methods examples of excel operations implemented by phpExcel |