diff --git a/app/common/service/UploadService.php b/app/common/service/UploadService.php index 71a29d7..e0197a6 100644 --- a/app/common/service/UploadService.php +++ b/app/common/service/UploadService.php @@ -24,6 +24,13 @@ class UploadService } $fileSize = $file->getSize(); + if ($fileSize > 20 * 1024 * 1024){ + return [ + 'code' => ResponseCode::FAIL, + 'msg' => '图片超出20M', + ]; + } + $uploadDir = '/files/' . $type . '/' . date('Ym') . '/'; $filename = date('YmdHis') . rand(999, 99999); $uploadPath = $uploadDir . $filename . '.' . $ext; @@ -67,12 +74,19 @@ class UploadService if ($file && $file->isValid()) { $ext = $file->getUploadExtension(); - if (in_array($ext, ['pdf', 'doc', 'docx', 'xlsx', 'xls', 'csv', 'pptx', 'ppt', 'zip', 'jpg', 'jpeg', 'png', 'gif', 'bmp', 'JPG', 'JPEG', 'PBG', 'txt'])) { + if (in_array($ext, ['pdf', 'doc', 'docx', 'xlsx', 'xls', 'csv', 'pptx', 'ppt', 'zip', 'jpg', 'jpeg', 'png', 'gif', 'bmp', 'JPG', 'JPEG', 'PBG', 'txt', 'zip', 'rar', '7z', 'tgz'])) { $type = 'files'; } else { $type = 'other'; } $fileSize = $file->getSize(); + + if ($fileSize > 20 * 1024 * 1024){ + return [ + 'code' => ResponseCode::FAIL, + 'msg' => '文件超出20M', + ]; + } $origin_name = $file->getUploadName(); $uploadDir = '/files/' . $type . '/' . date('Ym') . '/'; diff --git a/config/server.php b/config/server.php index 5829aa2..cb0577b 100644 --- a/config/server.php +++ b/config/server.php @@ -27,5 +27,5 @@ return [ 'status_file' => runtime_path() . '/webman.status', 'stdout_file' => runtime_path() . '/logs/stdout.log', 'log_file' => runtime_path() . '/logs/workerman.log', - 'max_package_size' => 10 * 1024 * 1024 + 'max_package_size' => 20 * 1024 * 1024 ];