From e243675bcced9b22a794dacf0c6d26debd55d9b6 Mon Sep 17 00:00:00 2001 From: liuweiwen <“529520975@qq.com> Date: Tue, 18 Feb 2020 15:18:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E5=AD=90=E7=AA=97=E5=8F=A3=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E8=BD=AC=E5=88=B0ajax=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Controller/AjaxController.class.php | 53 +++++++++++++++++++ .../Controller/PartnerController.class.php | 49 ----------------- Application/Admin/View/Partner/add.html | 4 +- Application/Admin/View/Partner/addfile.html | 2 +- Application/Admin/View/Partner/edit.html | 4 +- 5 files changed, 58 insertions(+), 54 deletions(-) diff --git a/Application/Admin/Controller/AjaxController.class.php b/Application/Admin/Controller/AjaxController.class.php index 90a5f3ba0..012a7a5ff 100644 --- a/Application/Admin/Controller/AjaxController.class.php +++ b/Application/Admin/Controller/AjaxController.class.php @@ -469,4 +469,57 @@ class AjaxController extends ThinkController{ } + public function addfile() + { + $this->meta_title = '文档添加'; + $template = I('t'); + $template = $template ?: 'Partner/addfile'; + return $this->display($template); + } + + //处理上传图片 + public function saveFile() + { + $path = '/Uploads/'; + $upload = new \Think\Upload();// 实例化上传类 + $upload->maxSize = 0 ;// 设置附件上传大小 + $upload->exts = '';// 设置附件上传类型 + $upload->rootPath = '.'.$path; // 设置附件上传根目录 + $upload->savePath = ''; // 设置附件上传(子)目录 + // 上传文件 + $info = $upload->upload(); + // dump($info); + if(!$info) {// 上传错误提示错误信息 + $msg = $upload->getError(); + $array= array('status' => 0, 'info' => $msg); + }else{// 上传成功 + $array=array( + "info"=>"上传成功", + "status"=>1, + "file_path"=>$path.$info['file']['savepath'].$info['file']['savename'], + "file_name"=>$_POST['file_name'], + "file_type"=>$_FILES['file']['type'], + "file_size"=>$_FILES['file']['size'], + "upload_time"=>date("Y-m-d H:i:s",time()) + ); + } + $this->ajaxReturn($array); + } + //删除图片 + public function delFile() + { + $id = $_REQUEST['id']; + $index = $_REQUEST['index'] ?: false; + $file_path = $_REQUEST['file_path'] ?: false; + if($id == 0){ + //未存入数据库,不用管 + unlink("./".$file_path); + $this->ajaxReturn(array( + 'status' => 1, + 'info' => "删除成功" + )); + } + # code... + } + } \ No newline at end of file diff --git a/Application/Admin/Controller/PartnerController.class.php b/Application/Admin/Controller/PartnerController.class.php index b4ba3211c..a6a473368 100644 --- a/Application/Admin/Controller/PartnerController.class.php +++ b/Application/Admin/Controller/PartnerController.class.php @@ -412,55 +412,6 @@ class PartnerController extends ThinkController $this->success('删除成功', U('lists')); } - public function addfile() - { - $this->meta_title = '文档添加'; - return $this->display(); - } - //处理上传图片 - public function saveFile() - { - $path = '/Uploads/'; - $upload = new \Think\Upload();// 实例化上传类 - $upload->maxSize = 0 ;// 设置附件上传大小 - $upload->exts = '';// 设置附件上传类型 - $upload->rootPath = '.'.$path; // 设置附件上传根目录 - $upload->savePath = ''; // 设置附件上传(子)目录 - // 上传文件 - $info = $upload->upload(); - // dump($info); - if(!$info) {// 上传错误提示错误信息 - $msg = $upload->getError(); - $array= array('status' => 0, 'info' => $msg); - }else{// 上传成功 - $array=array( - "info"=>"上传成功", - "status"=>1, - "file_path"=>$path.$info['file']['savepath'].$info['file']['savename'], - "file_name"=>$_POST['file_name'], - "file_type"=>$_FILES['file']['type'], - "file_size"=>$_FILES['file']['size'], - "upload_time"=>date("Y-m-d H:i:s",time()) - ); - } - $this->ajaxReturn($array); - } - //删除图片 - public function delFile() - { - $id = $_REQUEST['id']; - $index = $_REQUEST['index'] ?: false; - $file_path = $_REQUEST['file_path'] ?: false; - if($id == 0){ - //未存入数据库,不用管 - unlink("./".$file_path); - $this->ajaxReturn(array( - 'status' => 1, - 'info' => "删除成功" - )); - } - # code... - } } diff --git a/Application/Admin/View/Partner/add.html b/Application/Admin/View/Partner/add.html index a65ba38e2..596e41090 100644 --- a/Application/Admin/View/Partner/add.html +++ b/Application/Admin/View/Partner/add.html @@ -186,7 +186,7 @@