diff --git a/app/Controller/Api/V1/ArticleController.php b/app/Controller/Api/V1/ArticleController.php index daa8e90..4c53fc6 100644 --- a/app/Controller/Api/V1/ArticleController.php +++ b/app/Controller/Api/V1/ArticleController.php @@ -336,7 +336,7 @@ class ArticleController extends CController public function uploadArticleImage() { $file = $this->request->file('image'); - if (!$file->isValid()) { + if (!$file || !$file->isValid()) { return $this->response->fail(); } @@ -463,7 +463,7 @@ class ArticleController extends CController ]); $file = $this->request->file('annex'); - if (!$file->isValid()) { + if (!$file || !$file->isValid()) { return $this->response->fail('上传文件验证失败!'); } diff --git a/app/Controller/Api/V1/TalkController.php b/app/Controller/Api/V1/TalkController.php index ed7da6b..83ae275 100644 --- a/app/Controller/Api/V1/TalkController.php +++ b/app/Controller/Api/V1/TalkController.php @@ -487,7 +487,7 @@ class TalkController extends CController ]); $file = $this->request->file('img'); - if (!$file->isValid()) { + if (!$file || !$file->isValid()) { return $this->response->fail(); } diff --git a/app/Controller/Api/V1/UploadController.php b/app/Controller/Api/V1/UploadController.php index dd4ee38..f1380fb 100644 --- a/app/Controller/Api/V1/UploadController.php +++ b/app/Controller/Api/V1/UploadController.php @@ -98,7 +98,7 @@ class UploadController extends CController 'split_num' => 'required' ]); - if (!$file->isValid()) { + if (!$file || !$file->isValid()) { return $this->response->fail(); }