增加响应下载辅助函数

Signed-off-by: 码龍 <695798354@qq.com>
pull/424/head
码龍 2022-12-02 03:21:46 +00:00 committed by Gitee
parent e7a5ee807f
commit a5a17ce761
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 16 additions and 0 deletions

View File

@ -512,3 +512,19 @@ EOT;
return $icon;
}
}
if (!function_exists('download')) {
/**
* 获取\think\response\Download对象实例
* @param string $filename 要下载的文件
* @param string $name 显示文件名
* @param bool $content 是否为内容
* @param integer $expire 有效期(秒)
* @param bool $openinBrowser 设置是否在浏览器中显示文件
* @return \think\response\Download
*/
function download($filename, $name = '', $content = false, $expire = 360, $openinBrowser = false)
{
return (new \app\common\library\response\Download($filename))->name($name)->isContent($content)->expire($expire)->openinBrowser($openinBrowser);
}
}