mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-53577 repository: Added maxbytes error message
Changing the error message that is displayed to users when they upload a file that is greater than the maximum upload size. Does not include all upload cases; focuses on those most used by students.
This commit is contained in:
parent
fed66ad9e2
commit
a2fb838e82
8 changed files with 54 additions and 9 deletions
|
@ -888,7 +888,9 @@ abstract class repository implements cacheable_object {
|
|||
// the file needs to copied to draft area
|
||||
$stored_file = self::get_moodle_file($source);
|
||||
if ($maxbytes != -1 && $stored_file->get_filesize() > $maxbytes) {
|
||||
throw new file_exception('maxbytes');
|
||||
$maxbytesdisplay = display_size($maxbytes);
|
||||
throw new file_exception('maxbytesfile', (object) array('file' => $filerecord['filename'],
|
||||
'size' => $maxbytesdisplay));
|
||||
}
|
||||
// Validate the size of the draft area.
|
||||
if (file_is_draft_area_limit_reached($draftitemid, $areamaxbytes, $stored_file->get_filesize())) {
|
||||
|
@ -1699,13 +1701,17 @@ abstract class repository implements cacheable_object {
|
|||
// files that are references to local files are already in moodle filepool
|
||||
// just validate the size
|
||||
if ($maxbytes > 0 && $file->get_filesize() > $maxbytes) {
|
||||
throw new file_exception('maxbytes');
|
||||
$maxbytesdisplay = display_size($maxbytes);
|
||||
throw new file_exception('maxbytesfile', (object) array('file' => $file->get_filename(),
|
||||
'size' => $maxbytesdisplay));
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
if ($maxbytes > 0 && $file->get_filesize() > $maxbytes) {
|
||||
// note that stored_file::get_filesize() also calls synchronisation
|
||||
throw new file_exception('maxbytes');
|
||||
$maxbytesdisplay = display_size($maxbytes);
|
||||
throw new file_exception('maxbytesfile', (object) array('file' => $file->get_filename(),
|
||||
'size' => $maxbytesdisplay));
|
||||
}
|
||||
$fs = get_file_storage();
|
||||
$contentexists = $fs->content_exists($file->get_contenthash());
|
||||
|
|
|
@ -283,7 +283,9 @@ switch ($action) {
|
|||
|
||||
// Check if exceed maxbytes.
|
||||
if ($maxbytes != -1 && filesize($downloadedfile['path']) > $maxbytes) {
|
||||
throw new file_exception('maxbytes');
|
||||
$maxbytesdisplay = display_size($maxbytes);
|
||||
throw new file_exception('maxbytesfile', (object) array('file' => $record->filename,
|
||||
'size' => $maxbytesdisplay));
|
||||
}
|
||||
|
||||
// Check if we exceed the max bytes of the area.
|
||||
|
|
|
@ -191,7 +191,9 @@ class repository_upload extends repository {
|
|||
}
|
||||
|
||||
if (($maxbytes!==-1) && (filesize($_FILES[$elname]['tmp_name']) > $maxbytes)) {
|
||||
throw new file_exception('maxbytesforfile', $_FILES[$elname]['name']);
|
||||
$maxbytesdisplay = display_size($maxbytes);
|
||||
throw new file_exception('maxbytesfile', (object) array('file' => $record->filename,
|
||||
'size' => $maxbytesdisplay));
|
||||
}
|
||||
|
||||
if (file_is_draft_area_limit_reached($record->itemid, $areamaxbytes, filesize($_FILES[$elname]['tmp_name']))) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue