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

PHP下载txt文件到浏览器

程序员文章站 2022-05-27 12:16:29
...
 //下载文件
			 header('Content-Type:application/octet-stream');
			 if(preg_match('/MSIE/',$_SERVER['HTTP_USER_AGENT'])){
			 	header('Content-Disposition:attachment;filename="'.str_replace("+","20%",urlencode($newFileName)).'"');
			 }else if(preg_match('/Firefox/',$_SERVER['HTTP_USER_AGENT'])){
			 	header('Content-Disposition:attachment;filename=*"utf8'.$newFileName.'"');
			 }else{
			 	header('Content-Disposition:attachment;filename="'.$newFileName.'"');
			 }

以上就介绍了PHP下载txt文件到浏览器,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。