Home > php教程 > PHP源码 > php下载excel文件,文件无法打开错误

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

PHP中文网
Release: 2016-05-25 17:00:21
Original
1192 people have browsed it

跳至

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 '
Copy after login
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template