|
|
|
@ -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()); |
|
|
|
|