Blogger Information
Blog 91
fans 2
comment 4
visits 127875
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
tp5多图上传
夏日的烈风的博客
Original
2829 people have browsed it

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]);



}

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post