优化上传组件
This commit is contained in:
@@ -10,7 +10,7 @@ namespace app\controller;
|
||||
|
||||
use think\facade\Session;
|
||||
use think\facade\Filesystem;
|
||||
use think\facade\Db;
|
||||
use app\model\Attach;
|
||||
|
||||
class Upload extends Base {
|
||||
|
||||
@@ -65,7 +65,7 @@ class Upload extends Base {
|
||||
}else{
|
||||
$map[] = ['type', '=', 'image'];
|
||||
}
|
||||
$list = Db::where($map)->name('Attach')->paginate($pageConfig);
|
||||
$list = Attach::where($map)->paginate($pageConfig);
|
||||
|
||||
$this->data = [
|
||||
'from' => $this->request->param('from'),
|
||||
@@ -121,7 +121,7 @@ class Upload extends Base {
|
||||
'query' => $this->request->param()
|
||||
];
|
||||
$map[] = ['type', '=', 'image'];
|
||||
$data = Db::where($map)->name('Attach')->paginate($pageConfig)->each(function($item, $key){
|
||||
$data = Attach::where($map)->paginate($pageConfig)->each(function($item, $key){
|
||||
$item['thumbURL'] = $item['url'];
|
||||
$item['oriURL'] = $item['url'];
|
||||
return $item;
|
||||
@@ -165,7 +165,8 @@ class Upload extends Base {
|
||||
$data['location'] = "/uploads/";
|
||||
$data['url'] = $data['location'] . $data['savepath'];
|
||||
$data['create_time'] = time();
|
||||
$data['id'] = Db::name('Attach')->insertGetId($data);
|
||||
$attach = Attach::create($data);
|
||||
$data['id'] = $attach->id;
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user