first commit

This commit is contained in:
编码猿
2024-09-27 01:32:49 +08:00
commit 28ebe05a64
7399 changed files with 1174529 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
<?php
/**
* 后台上传通用接口
* Class Upload
* @package app\admin\controller\api
*/
namespace app\admin\controller\api;
use app\admin\controller\AdminController;
use app\admin\service\QiniuService;
use think\Db;
class Upload extends AdminController {
/**
* 编辑器多图片上传
* @return \think\response\Json
*/
public function image() {
$files = request()->file();
if (is_array($files)) {
foreach ($files as $vo) {
$info = $vo->move('../public/static/uploads');
if ($info) {
$url[] = '/static/uploads/' . date('Ymd') . '/' . $info->getFilename();
} else {
return json(['code' => 1, 'msg' => $vo->getError()]);
}
}
} else {
$info = $files->move('../public/static/uploads');
if ($info) {
$url[] = '/static/uploads/' . date('Ymd') . '/' . $info->getFilename();
} else {
return json(['code' => 1, 'msg' => $files->getError()]);
}
}
//判断是否使用七牛云上传
$file_type = Db::name('SystemConfig')->where(['name' => 'FileType', 'group' => 'file'])->value('value');
if ($file_type == 2) {
foreach ($url as &$vo) {
$vo = QiniuService::upload($vo);
}
}
return json(['code' => 0, 'msg' => '上传成功!', 'url' => $url]);
}
}