From a5a17ce7617da4c553eeba53991852e5bfeef8ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A0=81=E9=BE=8D?= <695798354@qq.com> Date: Fri, 2 Dec 2022 03:21:46 +0000 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=93=8D=E5=BA=94=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E8=BE=85=E5=8A=A9=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 码龍 <695798354@qq.com> --- application/common.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/application/common.php b/application/common.php index a014f80b..009696e9 100755 --- a/application/common.php +++ b/application/common.php @@ -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); + } +} \ No newline at end of file