fix(web/image_hosting): check file size after converting to png format

This commit is contained in:
Baoshuo Ren 2022-10-13 20:33:02 +08:00
parent f21ee00a87
commit b548dd071c
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

View File

@ -81,6 +81,10 @@
imagepng($img, $_FILES["image_upload_file"]["tmp_name"]);
imagedestroy($img);
if (filesize($_FILES["image_upload_file"]["tmp_name"]) > 5242880) { // 5 MB
throwError('too_large');
}
$filename = uojRandAvaiableFileName('/image_hosting/', 10, '.png');
if (!move_uploaded_file($_FILES["image_upload_file"]["tmp_name"], UOJContext::storagePath().$filename)) {
throwError('unknown error');