mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-26 09:08:41 +00:00
fix(web/image_hosting): check file size after converting to png format
This commit is contained in:
parent
f21ee00a87
commit
b548dd071c
@ -81,6 +81,10 @@
|
|||||||
imagepng($img, $_FILES["image_upload_file"]["tmp_name"]);
|
imagepng($img, $_FILES["image_upload_file"]["tmp_name"]);
|
||||||
imagedestroy($img);
|
imagedestroy($img);
|
||||||
|
|
||||||
|
if (filesize($_FILES["image_upload_file"]["tmp_name"]) > 5242880) { // 5 MB
|
||||||
|
throwError('too_large');
|
||||||
|
}
|
||||||
|
|
||||||
$filename = uojRandAvaiableFileName('/image_hosting/', 10, '.png');
|
$filename = uojRandAvaiableFileName('/image_hosting/', 10, '.png');
|
||||||
if (!move_uploaded_file($_FILES["image_upload_file"]["tmp_name"], UOJContext::storagePath().$filename)) {
|
if (!move_uploaded_file($_FILES["image_upload_file"]["tmp_name"], UOJContext::storagePath().$filename)) {
|
||||||
throwError('unknown error');
|
throwError('unknown error');
|
||||||
|
Loading…
Reference in New Issue
Block a user