Commit bfa25336 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Notify admins if file upload fails because /tmp is too small

parent 98fa9c87
......@@ -519,6 +519,16 @@ $string['filetypenotallowed'] = 'You are not allowed to upload files of this typ
$string['virusrepeatsubject'] = 'Warning: %s is a repeat virus uploader.';
$string['virusrepeatmessage'] = 'The user %s has uploaded multiple files which have been scanned by a virus checker and found to be infected.';
$string['phpuploaderror'] = 'An error occurred during file upload: %s (Error code %s)';
$string['phpuploaderror_1'] = 'The uploaded file exceeds the upload_max_filesize directive in php.ini.';
$string['phpuploaderror_2'] = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.';
$string['phpuploaderror_3'] = 'The uploaded file was only partially uploaded.';
$string['phpuploaderror_4'] = 'No file was uploaded.';
$string['phpuploaderror_6'] = 'Missing a temporary folder.';
$string['phpuploaderror_7'] = 'Failed to write file to disk.';
$string['phpuploaderror_8'] = 'File upload stopped by extension.';
$string['adminphpuploaderror'] = 'A file upload error was probably caused by your server configuration.';
$string['youraccounthasbeensuspended'] = 'Your account has been suspended';
$string['youraccounthasbeensuspendedtext2'] = 'Your account at %s has been suspended by %s.'; // @todo: more info?
$string['youraccounthasbeensuspendedreasontext'] = "Your account at %s has been suspended by %s. Reason:\n\n%s";
......@@ -75,8 +75,23 @@ class upload_manager {
return get_string('uploadedfiletoobig');
if ($file['error'] == 1) {
return get_string('uploadedfiletoobig');
if ($file['error'] != UPLOAD_ERR_OK) {
$errormsg = get_string('phpuploaderror', 'mahara', get_string('phpuploaderror_' . $file['error']), $file['error']);
if ($file['error'] == UPLOAD_ERR_NO_TMP_DIR || $file['error'] == UPLOAD_ERR_CANT_WRITE) {
// The admin probably needs to fix this; notify them
// @TODO: Create a new activity type for general admin messages.
$message = (object) array(
'users' => get_column('usr', 'id', 'admin', 1),
'subject' => get_string('adminphpuploaderror'),
'message' => $errormsg,
activity_occurred('maharamessage', $message);
else if ($file['error'] == UPLOAD_ERR_INI_SIZE || $file['error'] == UPLOAD_ERR_FORM_SIZE) {
return get_string('uploadedfiletoobig');
if (!is_uploaded_file($file['tmp_name'])) {
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment