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