需要在浏览器(谷歌)中打开,这时需要修改 header部分;代码如下:
//模板下载
public function export_model()
{
$filename = date("Y-m-d-H-i-s",time()).".csv";
header("Content-type:unknown/unknown");
header("Content-Disposition:attachment;filename=".$filename);
header('Cache-Control:must-revalidate,post-check=0,pre-check=0');
header('Expires:0');
header('Pragma:public');
$str = "\""."账号"."\",\""."密码"."\"\n";
echo $str;
}