欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

php下载excel文件,文件无法打开错误

程序员文章站 2022-05-28 19:40:52
...
跳至
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.' 错误:未生产文件');
		    echo '