修改下载文件方法、数据库结构
This commit is contained in:
1 parent
0433d4f004
commit
9e4c77e3df
13 files changed
+47
-44
No files matched your search
@@ -44,19 +44,6 @@ function getCategory($str = 0)
|
||||
}
|
||||
|
||||
|
||||
// // 获取类别名称
|
||||
// function getCategoryTitle($id)
|
||||
// {
|
||||
// $category = new \app\system\model\Category;
|
||||
// // 根据id查询类别名
|
||||
// $value = $category
|
||||
// ->where('id',$id)
|
||||
// ->vlaue('title');
|
||||
// // 返回类别名
|
||||
// return $value;
|
||||
// }
|
||||
|
||||
|
||||
function nianjiList($riqi=0)
|
||||
{
|
||||
// 定义学年时间节点日期为每年的8月1日
|
||||
|
||||
@@ -64,3 +64,31 @@ function srcZc($str)
|
||||
return $categoryId;
|
||||
}
|
||||
|
||||
|
||||
// 下载文件
|
||||
function smDownload($url,$newname='')
|
||||
{
|
||||
$file = $url;
|
||||
|
||||
if(strlen($newname)==0)
|
||||
{
|
||||
$newname = filesize($file);
|
||||
}
|
||||
|
||||
|
||||
if (file_exists($file)) {
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename='.$newname);
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . filesize($file));
|
||||
ob_clean();
|
||||
flush();
|
||||
readfile($file);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -529,8 +529,8 @@ class Student extends BaseController
|
||||
// 下载表格模板
|
||||
public function download()
|
||||
{
|
||||
$download = new \think\response\Download('uploads\student\student_template.xlsx');
|
||||
return $download->name('student_template.xlsx');
|
||||
$url = public_path().'public\\uploads\\student\\student_template.xlsx';
|
||||
return smDownload($url,'学生名单模板.xlsx');
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loaded 3 of 13 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user