feat: 优化代码

This commit is contained in:
Ying
2023-07-03 10:05:58 +08:00
parent e26acaf455
commit e890ef1512
4 changed files with 130 additions and 71 deletions

View File

@@ -48,7 +48,10 @@ class Ajax extends AdminController
/**
* 文件上传
* @return Response|void
* @throws \Exception
* @throws DataNotFoundException
* @throws DbException
* @throws InvalidArgumentException
* @throws ModelNotFoundException
*/
public function upload()
{
@@ -72,7 +75,11 @@ class Ajax extends AdminController
public function getImage(): Response
{
if (request()->isPost()) {
$file = Upload::instance()->download(input('url'));
$url = request()->post('url');
if (empty($url)) {
return $this->error('图片地址不能为空');
}
$file = Upload::instance()->download($url);
if (!$file) {
return $this->error(Upload::instance()->getError());
}