MDL-69257 core_h5p: Move $maxsize outside the foreach loop

There is no reason to repeatedly obtain the maximum size for uploading
files as a part of foreach loop.
This commit is contained in:
Mihail Geshoski 2020-10-09 10:23:28 +08:00
parent 2355205ad8
commit 2212df5dd8

View File

@ -75,10 +75,10 @@ switch ($action) {
$token = required_param('token', PARAM_RAW);
$contentid = required_param('contentId', PARAM_INT);
$maxsize = get_max_upload_file_size($CFG->maxbytes);
// Check size of each uploaded file and scan for viruses.
foreach ($_FILES as $uploadedfile) {
$filename = clean_param($uploadedfile['name'], PARAM_FILE);
$maxsize = get_max_upload_file_size($CFG->maxbytes);
if ($uploadedfile['size'] > $maxsize) {
H5PCore::ajaxError(get_string('maxbytesfile', 'error', ['file' => $filename, 'size' => display_size($maxsize)]));
return;