master
elf 4 months ago
parent e85948b2a5
commit 10753da02c

@ -15,6 +15,7 @@ use Admin\Event\QiNiuEvent;
use Think\Model;
use Think\Upload;
use Base\Service\OssService;
use Base\Tool\Storage;
/**
* 图片模型
@ -70,15 +71,14 @@ class PictureModel extends Model{
$this->where(['id'=>$value['id']])->save($data);
}
}
if (C('OSS_STATUS')) {
if (C('STORAGE_TYPE')) {
$path = explode('/', $value['path']);
$saveFileName = 'icon/' . $path[4];
$localFilePath = '.' . $value['path'];
$ossService = new OssService();
$result = $ossService->upload($localFilePath, $saveFileName);
$result = Storage::upload($localFilePath, $saveFileName);
if ($result['status']) {
$dataUrl['oss_url'] = $ossService->getUrl($saveFileName);
$coo = $this->where(['id' => $value['id']])->save($dataUrl);
$dataUrl['oss_url'] = $result['data']['url'];
$this->where(['id' => $value['id']])->save($dataUrl);
} else {
$this->error = $result['message'];
return false;

@ -11,6 +11,7 @@ namespace Home\Model;
use Think\Model;
use Think\Upload;
use Base\Service\OssService;
use Base\Tool\Storage;
/**
* 图片模型
@ -56,15 +57,14 @@ class PictureModel extends Model{
unset($info[$key]);
}
}
if (C('OSS_STATUS')) {
if (C('STORAGE_TYPE')) {
$path = explode('/', $value['path']);
$saveFileName = 'icon/' . $path[4];
$localFilePath = '.' . $value['path'];
$ossService = new OssService();
$ossService->upload($localFilePath, $saveFileName);
$result = Storage::upload($localFilePath, $saveFileName);
if ($result['status']) {
$dataUrl['oss_url'] = $ossService->getUrl($saveFileName);
$coo = $this->where(['id' => $value['id']])->save($dataUrl);
$dataUrl['oss_url'] = $result['data']['url'];
$this->where(['id' => $value['id']])->save($dataUrl);
} else {
$this->error = $result['message'];
return false;

Loading…
Cancel
Save