From 626e63597ebb41bdf550f5228e6464ce2b457165 Mon Sep 17 00:00:00 2001 From: win7 Date: Thu, 26 Dec 2019 12:50:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B7=B2=E7=9F=A5=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common.php | 38 +++++++++++++++++++++++++++++++ app/index/view/index/welcome.html | 4 ++-- app/middleware/Auth.php | 2 +- app/renshi/common.php | 28 ----------------------- app/system/controller/Fields.php | 30 +++++++----------------- 5 files changed, 49 insertions(+), 53 deletions(-) diff --git a/app/common.php b/app/common.php index d8ede17e..846a4d1f 100644 --- a/app/common.php +++ b/app/common.php @@ -363,6 +363,44 @@ function strToarray($str) } } return $str; +} + + + +/** + * 下载文件 + * + * @access public + * @param $url 文件地址 + * @param $newname 新文件名 + * @return array 返回类型 + */ +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; + } + + return true; } diff --git a/app/index/view/index/welcome.html b/app/index/view/index/welcome.html index 8c4822fb..0d80818d 100644 --- a/app/index/view/index/welcome.html +++ b/app/index/view/index/welcome.html @@ -22,8 +22,8 @@
-
欢迎『{$list.group}』: - {$list['xingming']}!当前时间: +
欢迎『{$list.group}』  + {$list['xingming']}    当前时间:
diff --git a/app/middleware/Auth.php b/app/middleware/Auth.php index 82a8e1c1..101867d5 100644 --- a/app/middleware/Auth.php +++ b/app/middleware/Auth.php @@ -53,7 +53,7 @@ class Auth // 批量保存 'saveall', // 下载成绩表、下载成绩统计表 - 'dwchengjixlsx','dwbanjixlsx','dwnianjixlsx', + 'dwchengjixlsx','dwbanjixls','dwnianjixlsx', //保存考号、下载试卷标签、下载成绩采集表 'updateset','biaoqianxls','dwcaiji', //课题结题图片上传和更新 diff --git a/app/renshi/common.php b/app/renshi/common.php index 5f621351..4794dbf1 100644 --- a/app/renshi/common.php +++ b/app/renshi/common.php @@ -65,34 +65,6 @@ function srcZc($str) } -// 下载文件 -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; - } -} - - /** * 将“一年级一班”格式的班级名转换成入学年和班级排序 diff --git a/app/system/controller/Fields.php b/app/system/controller/Fields.php index 247780b3..82c66005 100644 --- a/app/system/controller/Fields.php +++ b/app/system/controller/Fields.php @@ -75,30 +75,16 @@ class Fields extends BaseController $fl = new FL; // 查询文件信息 $filist = $fl->where('id',$id)->find(); + if($filist->oldname == null) + { + $oldname = $filist->newname; + }else{ + $oldname = $filist->oldname; + } $url = public_path().'public\\uploads\\'.$filist->url; - $name = $filist->oldname; - - // 临时代替代码 - if(!file_exists($url)) - { - echo "文件找不到"; - return true; - }else{ - header('content-type:text/html;charset=utf8'); - header('Content-Description: File Transfer'); - header('Content-Type: application/octet-stream'); - header('Content-Disposition: attachment; filename='.basename($url)); - 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($url)); - readfile($url); - } - $data = ['msg'=>'数据上传成功','val'=>1]; - - // return download($url,$name); + return smDownload($url,$oldname); + }