Browse Source

新增链接上传文件流程

master
wanghongjun 2 months ago
parent
commit
723c40f6ad
  1. 15
      app/common/controller/Upload.php

15
app/common/controller/Upload.php

@ -206,11 +206,20 @@ class Upload extends BaseController
if (empty($image_url)) {
throw new \Exception(lang('file.exist'));
}
$data = $this->downloadImage($image_url);
if (!$data['status']) {
$type = $param['type'] ?? 'image';
if ($type == 'image') {
$data = $this->downloadImage($image_url);
if (!$data['status']) {
throw new \Exception(lang('file.error'));
}
$info=$this->upload($param,$data['path'],'', false);
} elseif ($type == 'file') {
$main_host = getMainHost();
$path = public_path() . '/' . ltrim(str_replace($main_host,'',$image_url),'/');
$info = $this->upload($param,$path,'', false);
} else {
throw new \Exception(lang('file.error'));
}
$info=$this->upload($param,$data['path'],'', false);
return success(lang('file.uploadOk'),$info);
} catch(\Exception $e) {
return error($e->getMessage());

Loading…
Cancel
Save