PHP readfile实现文件下载

public function down_template()
{
        $file = PUBLIC_DIR.'/门店导入模板.xls';
        header('Content-Disposition: attachment; filename=门店导入模板.xls');
        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
        header('Content-Length: '.filesize($file));
        header('Content-Transfer-Encoding: binary');
        header('Cache-Control: must-revalidate');
        header('Pragma: public');
        readfile($file);
        exit;
}
发布了36 篇原创文章 · 获赞 4 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/m0_37826705/article/details/100010317