博客列表 >tp5多图上传

tp5多图上传

夏日的烈风的博客
夏日的烈风的博客原创
2019年01月09日 08:39:052819浏览

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



}

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议