添加上传大小限制20M
This commit is contained in:
parent
9a4f207d37
commit
b163364831
@ -24,6 +24,13 @@ class UploadService
|
|||||||
}
|
}
|
||||||
$fileSize = $file->getSize();
|
$fileSize = $file->getSize();
|
||||||
|
|
||||||
|
if ($fileSize > 20 * 1024 * 1024){
|
||||||
|
return [
|
||||||
|
'code' => ResponseCode::FAIL,
|
||||||
|
'msg' => '图片超出20M',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
$uploadDir = '/files/' . $type . '/' . date('Ym') . '/';
|
$uploadDir = '/files/' . $type . '/' . date('Ym') . '/';
|
||||||
$filename = date('YmdHis') . rand(999, 99999);
|
$filename = date('YmdHis') . rand(999, 99999);
|
||||||
$uploadPath = $uploadDir . $filename . '.' . $ext;
|
$uploadPath = $uploadDir . $filename . '.' . $ext;
|
||||||
@ -67,12 +74,19 @@ class UploadService
|
|||||||
|
|
||||||
if ($file && $file->isValid()) {
|
if ($file && $file->isValid()) {
|
||||||
$ext = $file->getUploadExtension();
|
$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';
|
$type = 'files';
|
||||||
} else {
|
} else {
|
||||||
$type = 'other';
|
$type = 'other';
|
||||||
}
|
}
|
||||||
$fileSize = $file->getSize();
|
$fileSize = $file->getSize();
|
||||||
|
|
||||||
|
if ($fileSize > 20 * 1024 * 1024){
|
||||||
|
return [
|
||||||
|
'code' => ResponseCode::FAIL,
|
||||||
|
'msg' => '文件超出20M',
|
||||||
|
];
|
||||||
|
}
|
||||||
$origin_name = $file->getUploadName();
|
$origin_name = $file->getUploadName();
|
||||||
|
|
||||||
$uploadDir = '/files/' . $type . '/' . date('Ym') . '/';
|
$uploadDir = '/files/' . $type . '/' . date('Ym') . '/';
|
||||||
|
@ -27,5 +27,5 @@ return [
|
|||||||
'status_file' => runtime_path() . '/webman.status',
|
'status_file' => runtime_path() . '/webman.status',
|
||||||
'stdout_file' => runtime_path() . '/logs/stdout.log',
|
'stdout_file' => runtime_path() . '/logs/stdout.log',
|
||||||
'log_file' => runtime_path() . '/logs/workerman.log',
|
'log_file' => runtime_path() . '/logs/workerman.log',
|
||||||
'max_package_size' => 10 * 1024 * 1024
|
'max_package_size' => 20 * 1024 * 1024
|
||||||
];
|
];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user