From 56e8f4d29e1aa5cf9d648d401bfbd1e960948e64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=9D=BE=E6=A0=91?= Date: Tue, 16 Apr 2019 16:52:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=88=E7=94=9F=E5=90=8D=E5=8D=95=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common.php | 4 +-- application/renshi/controller/Index.php | 2 +- application/renshi/controller/Student.php | 33 ++++--------------- application/renshi/view/index/create_all.html | 2 +- .../renshi/view/student/create_all.html | 8 ++--- 5 files changed, 15 insertions(+), 34 deletions(-) diff --git a/application/common.php b/application/common.php index 5f21c3ad..b4551575 100644 --- a/application/common.php +++ b/application/common.php @@ -196,7 +196,7 @@ function teacherNames($list = array()) function upload($list,$file) { // 移动到框架应用根目录/uploads/ 目录下 - $info = $file->move($list['url']); + $info = $file->move($list['serurl']); // 如果上传成功 if($info){ @@ -226,7 +226,7 @@ function upload($list,$file) $data = array( 'msg'=>'上传成功' ,'val'=>true - ,'url'=>'..\public\uploads\teacher\\'.$list['url'] + ,'url'=>$list['serurl'].$list['url'] ); }else{ $data = array( diff --git a/application/renshi/controller/Index.php b/application/renshi/controller/Index.php index 7a8c3a95..814f0243 100644 --- a/application/renshi/controller/Index.php +++ b/application/renshi/controller/Index.php @@ -380,7 +380,7 @@ class Index extends Base { // 获取文件信息 $list['text'] = $this->request->post('text'); - $list['url'] = $this->request->post('url'); + $list['serurl'] = $this->request->post('serurl'); // 获取表单上传文件 $file = request()->file('file'); diff --git a/application/renshi/controller/Student.php b/application/renshi/controller/Student.php index 77e62009..5d409894 100644 --- a/application/renshi/controller/Student.php +++ b/application/renshi/controller/Student.php @@ -264,7 +264,7 @@ class Student extends Base // 判断表格是否正确 if($stuinfo[0][0] != "学生信息上传模板" ) { - $data = array('msg'=>'请使用模板上传','val'=>false,'url'=>null); + $data = array('msg'=>'请使用模板上传','val'=>0,'url'=>null); return json($data); } @@ -333,9 +333,7 @@ class Student extends Base $data = $student->saveAll($students); // $cnt = $data->count(); - $data ? $data = ['msg'=>'数据同步成功','val'=>true] : ['msg'=>'数据同步失败','val'=>false]; - - + $data ? $data = ['msg'=>'数据同步成功','val'=>1] : ['msg'=>'数据同步失败','val'=>0]; return json($data); } @@ -346,31 +344,14 @@ class Student extends Base public function upload() { // 获取文件信息 - $list['text'] = '学生名单'; - $list['oldname']=input('post.name'); - $list['bianjitime'] = input('post.lastModifiedDate'); - $list['fieldsize'] = input('post.size'); + $list['text'] = $this->request->post('text'); + $list['serurl'] = $this->request->post('serurl'); - // 获取表单上传文件 例如上传了001.jpg + // 获取表单上传文件 $file = request()->file('file'); - // 移动到框架应用根目录/uploads/ 目录下 - $info = $file->move( '..\public\uploads\student'); - if($info){ - // 成功上传后 获取上传信息 - $list['category'] = $info->getExtension(); - $list['url'] = $info->getSaveName(); - $list['newname'] = $info->getFilename(); + // 上传文件并返回结果 + $data = upload($list,$file); - //将文件信息保存 - $data = Fields::create($list); - - $data ? $data = array('msg'=>'上传成功','val'=>true,'url'=>'..\public\uploads\student\\'.$list['url']) : $data = array('msg'=>'保存文件信息失败','val'=>false,'url'=>null); - }else{ - // 上传失败获取错误信息 - $data = array('msg'=>$file->getError(),'val'=>false,'url'=>null); - } - - // 返回信息 return json($data); } diff --git a/application/renshi/view/index/create_all.html b/application/renshi/view/index/create_all.html index da1b9f6c..0c033043 100644 --- a/application/renshi/view/index/create_all.html +++ b/application/renshi/view/index/create_all.html @@ -61,7 +61,7 @@ layui.use('upload', function(){ } ,data: { text: '教师信息' - ,url:'..\\public\\uploads\\teacher' + ,serurl:'..\\public\\uploads\\teacher\\' } ,acceptMime:'.xls,.xlsx' diff --git a/application/renshi/view/student/create_all.html b/application/renshi/view/student/create_all.html index da1b9f6c..03826671 100644 --- a/application/renshi/view/student/create_all.html +++ b/application/renshi/view/student/create_all.html @@ -17,9 +17,9 @@
- +
- {php} $schoollist = schlist('校级','区级');{/php} + {php} $schoollist = schlist('校级','校级');{/php}