在线网站建设费用是多少,成都航空公司官方网站,医疗器械网站建设方案,有做模仿易企秀网站吗php下载excel文件,1、在下载的过程中不要 输出任何非文件信息#xff0c;比如 echo log信息。 否则下载后的文件无法打开#xff0c;提示格式错误或者文件被破坏。2、 输出的excel格式一定要和后缀名保存一直#xff0c;否也会提示格式错误或者文件被破坏if (file_exists(CA…php下载excel文件,1、在下载的过程中不要 输出任何非文件信息比如 echo log信息。 否则下载后的文件无法打开提示格式错误或者文件被破坏。2、 输出的excel格式一定要和后缀名保存一直否也会提示格式错误或者文件被破坏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-check0, pre-check0‘ );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.‘ 错误未生产文件‘);echo ‘‘;}原文http://www.jb51.net/article/44774.htm