1
1
mirror of https://github.com/renbaoshuo/S2OJ.git synced 2025-04-21 09:04:36 +00:00

fix(web/image_hosting): image size calc

This commit is contained in:
Baoshuo Ren 2022-10-13 20:54:47 +08:00
parent 0ecf295a38
commit 2e51c20d9f
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

@ -22,7 +22,7 @@
die(json_encode(['status' => 'error', 'message' => $msg]));
}
$allowedTypes = [IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_GIF];
$allowedTypes = [IMAGETYPE_PNG, IMAGETYPE_JPEG];
if ($_POST['image_upload_file_submit'] == 'submit') {
header('Content-Type: application/json');
@ -81,7 +81,7 @@
imagepng($img, $_FILES["image_upload_file"]["tmp_name"]);
imagedestroy($img);
if (filesize($_FILES["image_upload_file"]["tmp_name"]) > 5242880) { // 5 MB
if (($size = filesize($_FILES["image_upload_file"]["tmp_name"])) > 5242880) { // 5 MB
throwError('too_large');
}