直接修改这个两个文件即可,如果没效果,将data\runtime里面的缓存文件删除即可
模板文件路径:
目录\public\themes\admin_simpleboot3\user\admin_asset\index.html
<include file="public@header"/> </head> <body> <div class="wrap js-check-wrap"> <ul class="nav nav-tabs"> <li class="active"><a href="{:url('AdminAsset/index')}">资源列表</a></li> </ul> <!--新增搜索框--> <form class="well form-inline margin-top-20" method="post" action="{:url('AdminAsset/search',array())}"> <input type="text" class="form-control" name="filename" style="width: 200px;" value="" placeholder="请输入关键字..."> <input type="submit" class="btn btn-primary" value="搜索"> <a class="btn btn-danger" href="{:url('AdminAsset/index')}">清空</a> </form> <!--新增功能按钮--> <form class="js-ajax-form" action="" method="post" novalidate="novalidate"> <div class="table-actions"> <a class="btn btn-sm btn-info" href="javascript:uploadMultiImage('图片上传','#photos','photos-item-tpl');" >图片上传</a> <a class="btn btn-sm btn-warning" href="javascript:uploadMultiFile('附件上传','#files','files-item-tpl','file');">文件上传</a> <button class="btn btn-sm btn-danger js-ajax-submit" type="submit" data-action="{:url('AdminAsset/Multidelete',array())}" data-subcheck="true" data-msg="您确定删除吗?">批量删除</button> </div> <php>$status=['不可用', '可用'];</php> <table class="table table-hover table-bordered margin-top-20"> <thead> <tr> <th width="50"><input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x"></th> <th width="50">ID</th> <th>用户</th> <th>文件大小</th> <th>文件名</th> <th>图像</th> <th>文件路径</th> <th>状态</th> <th width="160">{:lang('ACTIONS')}</th> </tr> </thead> <tbody> <php> $asset_img_suffixes=['bmp','jpg','jpeg','png','gif','tiff'];/*TODO ADD MORE*/ </php> <foreach name="assets" item="vo"> <tr> <td> <input type="checkbox" class="js-check" name="id[]" data-yid="js-check-y" data-xid="js-check-x" value="{$vo.id}" title="ID:{$vo.id}"></td> <td>{$vo.id}</td> <td> 用户ID:{$vo.user_id} {$vo.user_login} {$vo.user_nickname} </td> <td>{$vo.file_size/1024|round}KB</td> <td>{$vo.filename}</td> <td> <if condition="in_array(strtolower($vo['suffix']),$asset_img_suffixes)"> <a href="javascript:parent.imagePreviewDialog('{:cmf_get_image_preview_url($vo['file_path'])}');"> <i class="fa fa-photo fa-fw"></i> </a> </if> </td> <td> {$vo.file_path} <if condition="!file_exists('upload/'.$vo['file_path'])"> <span style='color:red;'>  (文件丢失)</span> </if> </td> <td>{$status[$vo['status']]}</td> <td> <a href="{:url('AdminAsset/delete',array('id'=>$vo['id']))}" class="js-ajax-delete">{:lang('DELETE')}</a> </td> </tr> </foreach> </tbody> </table> <div class="pagination">{$page|default=''}</div> </form> </div> <script src="__STATIC__/js/admin.js"></script> </body> </html> <!--多图片上传模板--> <div class="col-md-6 col-sm-10" id="photos"><div> <img id="photos-item-tpl" width="0" height="0" style="cursor: pointer"> <!--多图片上传模板--> <!--多文件上传模板--> <div class="col-md-6 col-sm-10" id="files"><div> <div id="files-item-tpl"></div> <!--多文件上传模板-->
模板控制器新增方法:
目录\app\user\controller\AdminAssetController.php
<?php // +---------------------------------------------------------------------- // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ] // +---------------------------------------------------------------------- // | Copyright (c) 2013-2018 http://www.thinkcmf.com All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: 小夏 < 449134904@qq.com> // | 二次修改 xzw 2018/8/19 // +---------------------------------------------------------------------- namespace app\user\controller; use think\Db; use cmf\controller\AdminBaseController; class AdminAssetController extends AdminBaseController { /** * 资源管理列表 * @adminMenu( * 'name' => '资源管理', * 'parent' => '', * 'display'=> false, * 'hasView'=> true, * 'order' => 10000, * 'icon' => 'file', * 'remark' => '资源管理列表', * 'param' => '' * ) */ public function index() { $join = [ ['__USER__ u', 'a.user_id = u.id'] ]; $result = Db::name('asset')->field('a.*,u.user_login,u.user_email,u.user_nickname') ->alias('a')->join($join) ->order('create_time', 'DESC') ->paginate(10); $this->assign('assets', $result->items()); $this->assign('page', $result->render()); return $this->fetch(); } /** * 删除文件 * @adminMenu( * 'name' => '删除文件', * 'parent' => 'index', * 'display'=> false, * 'hasView'=> false, * 'order' => 10000, * 'icon' => '', * 'remark' => '删除文件', * 'param' => '' * ) */ public function delete() { $id = $this->request->param('id'); $file_filePath = Db::name('asset')->where('id', $id)->value('file_path'); $file = 'upload/' . $file_filePath; $res = true; if (file_exists($file)) { $res = unlink($file); } if ($res) { Db::name('asset')->where('id', $id)->delete(); $this->success('删除成功'); } else { $this->error('删除失败'); } } /** * 批量删除文件 * @adminMenu( * 'name' => '批量删除文件', * 'parent' => 'index', * 'display'=> false, * 'hasView'=> false, * 'order' => 10000, * 'icon' => '', * 'remark' => '批量删除文件', * 'param' => 'id[]' * ) */ public function Multidelete() { $Aid = $this->request->param()['id']; $success=[]; $error=[]; foreach ($Aid as $id ) { $file_filePath = Db::name('asset')->where('id', $id)->value('file_path'); $file = 'upload/' . $file_filePath; $res = true; if (file_exists($file)) { $res = unlink($file); } if ($res) { Db::name('asset')->where('id', $id)->delete(); $success[]=['id'=>$id,'res'=>'删除成功']; } else { $error[]=['id'=>$id,'res'=>'删除失败']; } } if(count($success)>0) { $this->success('批量删除成功:'.count($success).",删除失败:".count($error)); } else { $this->error('批量删除成功:'.count($success).",删除失败:".count($error)); } } /** * 搜索文件 * @adminMenu( * 'name' => '搜索文件', * 'parent' => 'index', * 'display'=> false, * 'hasView'=> false, * 'order' => 10000, * 'icon' => '', * 'remark' => '搜索文件', * 'param' => 'filename' * ) */ public function search() { $filename = trim($this->request->param('filename')); $join = [ ['__USER__ u', 'a.user_id = u.id'] ]; $where['filename']=['like',"%".$filename."%"]; $result =Db::name('asset') ->field('a.*,u.user_login,u.user_email,u.user_nickname') ->alias('a')->join($join) ->order('create_time', 'DESC') ->where("filename","like","%".$filename."%") ->paginate(10); $this->assign('assets', $result->items()); $this->assign('page', $result->render()); return $this->fetch("index"); } }
PS:资源管理默认是在左上角的小图标,开启左侧菜单在
资源管理:user/AdminAsset/index
最终效果:
0.话题发布后没及时显示,请联系官方QQ群管理;
1.话题支持代码,qq截屏直接粘贴,和QQ群一样;
2.问题描述清,比如服务器版本,程序版本;
3.能上代码,就不用文字;
4.把问题发到话题后再发QQ群;
5.如果感觉回复者解答的不错,可以发红包!
6.多帮助别人也是对自己的锻炼!
7.付费讨论中只有提问者和付费用户才可以查看回复
1.评论积分+1;每天最多10次奖励
2.发布话题积分+1;每天最多5次奖励
3.垃圾评论积分-500;
4.黄色,暴力,违反我国法律评论直接封号