|
|
@@ -688,17 +688,18 @@ class User extends BaseController
|
|
|
* @return type
|
|
|
*/
|
|
|
public function upload(Request $request){
|
|
|
+ $uploadConfig = config('upload');
|
|
|
$sysData = (new SysModel())->where("id",1)->find();
|
|
|
$file = $request->file('file');
|
|
|
$code = $request->post("code","image");
|
|
|
if(empty($file)) {
|
|
|
return app('json')->fail("未上传文件");
|
|
|
}
|
|
|
- if(!in_array($code, ["avatar","video","image","circle","advert","goods","activity"])){
|
|
|
+ if(!in_array($code, $uploadConfig['image']['path'])){
|
|
|
return app('json')->fail("上传路径错误");
|
|
|
}
|
|
|
$ext = $file->extension();
|
|
|
- if(!in_array($ext, array("png","jpeg","gif","jpg"))){
|
|
|
+ if(!in_array($ext, $uploadConfig['image']['ext'])){
|
|
|
return app('json')->fail("图片类型错误");
|
|
|
}
|
|
|
$upPath = \think\facade\Filesystem::disk('resource')->putFile( $code, $file);
|
|
|
@@ -716,17 +717,18 @@ class User extends BaseController
|
|
|
* @return type
|
|
|
*/
|
|
|
public function uploadVideo(Request $request){
|
|
|
+ $uploadConfig = config('upload');
|
|
|
$sysData = (new SysModel())->where("id",1)->find();
|
|
|
$file = $request->file('file');
|
|
|
$code = $request->post("code","video");
|
|
|
if(empty($file)) {
|
|
|
return app('json')->fail("未上传文件");
|
|
|
}
|
|
|
- if(!in_array($code, ["video"])){
|
|
|
+ if(!in_array($code, $uploadConfig['video']['path'])){
|
|
|
return app('json')->fail("上传路径错误");
|
|
|
}
|
|
|
$ext = $file->extension();
|
|
|
- if(!in_array($ext, array("mp4","megp4"))){
|
|
|
+ if(!in_array($ext, $uploadConfig['video']['ext'])){
|
|
|
return app('json')->fail("视频类型错误");
|
|
|
}
|
|
|
$upPath = \think\facade\Filesystem::disk('resource')->putFile( $code, $file);
|