Browse Source

朋友圈上传图片,改为多张

master
wanghongjun 7 months ago
parent
commit
227bcea2d5
  1. 21
      app/common/controller/Upload.php

21
app/common/controller/Upload.php

@ -230,14 +230,21 @@ class Upload extends BaseController
public function uploadPosts(){ public function uploadPosts(){
$param=request::param(); $param=request::param();
try{ try{
$file=request()->file('file'); $files=request()->file('file');
$info=$this->upload($param,$file); $returnData = [];
$url=$this->url.$info['src']; if (!is_array($files)) {
$data = ['url' => $url, 'poster' => '']; $files = [$files];
if (isset($info['poster'])) { }
$data['poster']=$info['poster']; foreach ($files as $file) {
$info=$this->upload($param,$file);
$url=$this->url.$info['src'];
$data = ['url' => $url, 'poster' => ''];
if (isset($info['poster'])) {
$data['poster']=$info['poster'];
}
$returnData[] = $data;
} }
return success(lang('file.uploadOk'),$data); return success(lang('file.uploadOk'),$returnData);
} catch(\Exception $e) { } catch(\Exception $e) {
return error($e->getMessage()); return error($e->getMessage());
} }

Loading…
Cancel
Save