diff --git a/app/Controller/Api/V1/DownloadController.php b/app/Controller/Api/V1/DownloadController.php index 7d49914..ea761f1 100644 --- a/app/Controller/Api/V1/DownloadController.php +++ b/app/Controller/Api/V1/DownloadController.php @@ -18,7 +18,6 @@ use Hyperf\HttpServer\Contract\ResponseInterface; * Class DownloadController * * @Controller(path="/api/v1/download") - * @Middleware(JWTAuthMiddleware::class) * * @package App\Controller\Api\V1 */ diff --git a/app/Controller/Api/V1/EmoticonController.php b/app/Controller/Api/V1/EmoticonController.php index c3f602a..06ab830 100644 --- a/app/Controller/Api/V1/EmoticonController.php +++ b/app/Controller/Api/V1/EmoticonController.php @@ -155,7 +155,10 @@ class EmoticonController extends CController } // 读取图片信息 - $imgInfo = getimagesize($file->getPath()); + $imgInfo = @getimagesize($file->getRealPath()); + if(!$imgInfo){ + return $this->response->fail('表情包上传失败...'); + } $save_path = $uploadService->media($file, 'media/images/emoticon', create_image_name($ext, $imgInfo[0], $imgInfo[1])); if (!$save_path) { diff --git a/app/Service/UploadService.php b/app/Service/UploadService.php index f4b6d7e..4f880bd 100644 --- a/app/Service/UploadService.php +++ b/app/Service/UploadService.php @@ -49,6 +49,6 @@ class UploadService extends BaseService @chmod(sprintf('%s/%s', $save_dir, $filename), 0644); } - return $file->isMoved() ? sprintf('/%s/%s', trim($dir, '/'), $filename) : false; + return $file->isMoved() ? sprintf('%s/%s', trim($dir, '/'), $filename) : false; } } diff --git a/app/helper.php b/app/helper.php index 6a2eaa0..fcea62d 100644 --- a/app/helper.php +++ b/app/helper.php @@ -169,7 +169,7 @@ function diff_date($day1, $day2) */ function get_media_url(string $path) { - return config('domain.img_url') . $path; + return sprintf('%s/%s', rtrim(config('domain.img_url'), '/'), ltrim($path,'/')); } /**