|
@@ -1,4 +1,5 @@
|
|
|
<?php
|
|
|
+declare(strict_types=1);
|
|
|
|
|
|
/**
|
|
|
* upload文件管理
|
|
@@ -10,13 +11,14 @@
|
|
|
|
|
|
namespace app\sys\controller;
|
|
|
|
|
|
+use Exception;
|
|
|
use think\facade\View;
|
|
|
use think\File;
|
|
|
use think\Image;
|
|
|
use think\facade\Config;
|
|
|
|
|
|
use app\common\service\FileService;
|
|
|
-use Exception;
|
|
|
+use app\common\model\FileManager as FileManagerModel;
|
|
|
|
|
|
class FileManager extends Base
|
|
|
{
|
|
@@ -25,59 +27,43 @@ class FileManager extends Base
|
|
|
protected $height = 300;
|
|
|
|
|
|
/**
|
|
|
- * 处理上传的图片
|
|
|
+ * 图片列表
|
|
|
*/
|
|
|
- protected function dealUploadImg(File $file, $water, $thumb, $width, $height, $overwrite)
|
|
|
- {
|
|
|
- $savename = "";
|
|
|
- $thumbname = "";
|
|
|
+ // public function index($mod=0)
|
|
|
+ // {
|
|
|
|
|
|
- if ($water == true || $thumb == true) {
|
|
|
- $image = Image::open($file);
|
|
|
+ // }
|
|
|
|
|
|
- if ($water) {
|
|
|
- $type = $this->system->water_type ?: Config::get('filesystem.water.type');
|
|
|
+ public function index()
|
|
|
+ {
|
|
|
+ // $data = $this->explorer();
|
|
|
|
|
|
- if ($type == 'water') {
|
|
|
- $watemark = $this->system->watermark ?: Config::get('filesystem.water.watermark');
|
|
|
- $image->water($watemark);
|
|
|
- } else {
|
|
|
- $watetext = $this->system->watertext ?: Config::get('filesystem.water.watertext');
|
|
|
- $image->text($watetext, Config::get('filesystem.water.waterfont'), 30, '#ffffff30');
|
|
|
- }
|
|
|
- }
|
|
|
+ // View::assign('dirs', $data['dirs']);
|
|
|
+ // View::assign('files', $data['files']);
|
|
|
+ // View::assign('counts', $data['counts']);
|
|
|
+ // View::assign('activeurl', $data['activeurl']);
|
|
|
+ // View::assign('activepath', $data['activepath']);
|
|
|
|
|
|
- $savename = $file->hashName();
|
|
|
- $realPath = Config::get('filesystem.disks.public.root') . '/' . $savename;
|
|
|
+ $param = $this->request->param();
|
|
|
|
|
|
- if ($thumb == true) {
|
|
|
- if ($overwrite == true) {
|
|
|
- $image->thumb($width, $height, 1);
|
|
|
+ $param['limit'] = isset($param['limit']) ? (int) $param['limit'] : Config::get('app.page_size');
|
|
|
|
|
|
- $image->save($realPath);
|
|
|
- } else {
|
|
|
- $image->save($realPath);
|
|
|
+ $list = FileManagerModel::queryPage($param);
|
|
|
|
|
|
- $image->thumb($width, $height, 1);
|
|
|
+ View::assign('list', $list);
|
|
|
|
|
|
- $ext = $file->extension();
|
|
|
+ return View::fetch();
|
|
|
+ }
|
|
|
|
|
|
- $thumbname = str_replace('.' . $ext, '', str_replace('\\', '/', $savename)) . $this->t_suffix . '.' . $ext;
|
|
|
- // halt(Config::get('filesystem.disks.public.root') .'/' . $thumbname);
|
|
|
- $image->save(Config::get('filesystem.disks.public.root') . '/' . $thumbname);
|
|
|
- }
|
|
|
- } else {
|
|
|
- $image->save($realPath);
|
|
|
- }
|
|
|
- unset($image);
|
|
|
- } else {
|
|
|
- $savename = \think\facade\Filesystem::disk('public')->putFile('/', $file);
|
|
|
- }
|
|
|
+ public function uploadFile()
|
|
|
+ {
|
|
|
+ $files = $this->request->file('upload_file');
|
|
|
|
|
|
- return [
|
|
|
- 'picname' => str_replace('\\', '/', $savename),
|
|
|
- 'thumbname' => $thumbname
|
|
|
- ];
|
|
|
+ $savename = [];
|
|
|
+
|
|
|
+ foreach($files as $file){
|
|
|
+ $savename[] = \think\facade\Filesystem::disk('public')->putFile('/', $file);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -257,18 +243,7 @@ class FileManager extends Base
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
- public function index()
|
|
|
- {
|
|
|
- $data = $this->explorer();
|
|
|
|
|
|
- View::assign('dirs', $data['dirs']);
|
|
|
- View::assign('files', $data['files']);
|
|
|
- View::assign('counts', $data['counts']);
|
|
|
- View::assign('activeurl', $data['activeurl']);
|
|
|
- View::assign('activepath', $data['activepath']);
|
|
|
-
|
|
|
- return View::fetch();
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 获取当前文件相关信息
|
|
@@ -539,6 +514,62 @@ class FileManager extends Base
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
+ /**
|
|
|
+ * 处理上传的图片
|
|
|
+ */
|
|
|
+ protected function dealUploadImg(File $file, $water, $thumb, $width, $height, $overwrite)
|
|
|
+ {
|
|
|
+ $savename = "";
|
|
|
+ $thumbname = "";
|
|
|
+
|
|
|
+ if ($water == true || $thumb == true) {
|
|
|
+ $image = Image::open($file);
|
|
|
+
|
|
|
+ if ($water) {
|
|
|
+ $type = $this->system->water_type ?: Config::get('filesystem.water.type');
|
|
|
+
|
|
|
+ if ($type == 'water') {
|
|
|
+ $watemark = $this->system->watermark ?: Config::get('filesystem.water.watermark');
|
|
|
+ $image->water($watemark);
|
|
|
+ } else {
|
|
|
+ $watetext = $this->system->watertext ?: Config::get('filesystem.water.watertext');
|
|
|
+ $image->text($watetext, Config::get('filesystem.water.waterfont'), 30, '#ffffff30');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $savename = $file->hashName();
|
|
|
+ $realPath = Config::get('filesystem.disks.public.root') . '/' . $savename;
|
|
|
+
|
|
|
+ if ($thumb == true) {
|
|
|
+ if ($overwrite == true) {
|
|
|
+ $image->thumb($width, $height, 1);
|
|
|
+
|
|
|
+ $image->save($realPath);
|
|
|
+ } else {
|
|
|
+ $image->save($realPath);
|
|
|
+
|
|
|
+ $image->thumb($width, $height, 1);
|
|
|
+
|
|
|
+ $ext = $file->extension();
|
|
|
+
|
|
|
+ $thumbname = str_replace('.' . $ext, '', str_replace('\\', '/', $savename)) . $this->t_suffix . '.' . $ext;
|
|
|
+ // halt(Config::get('filesystem.disks.public.root') .'/' . $thumbname);
|
|
|
+ $image->save(Config::get('filesystem.disks.public.root') . '/' . $thumbname);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $image->save($realPath);
|
|
|
+ }
|
|
|
+ unset($image);
|
|
|
+ } else {
|
|
|
+ $savename = \think\facade\Filesystem::disk('public')->putFile('/', $file);
|
|
|
+ }
|
|
|
+
|
|
|
+ return [
|
|
|
+ 'picname' => str_replace('\\', '/', $savename),
|
|
|
+ 'thumbname' => $thumbname
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* ckeditor 富文本编辑器上传图片
|
|
|
*/
|