Skip to content

Commit

Permalink
MDL-44626 repository: Correct error message when uploading large files
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Feb 11, 2016
1 parent 9d5d9c6 commit 658a922
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lang/en/repository.php
Expand Up @@ -111,7 +111,7 @@
$string['errordoublereference'] = 'Unable to overwrite file with a shortcut/alias because shortcuts to this file already exist.';
$string['errornotyourfile'] = 'You cannot pick file which is not added by your';
$string['erroruniquename'] = 'Repository instance name should be unique';
$string['errorpostmaxsize'] = 'The uploaded file may exceed the post_max_size directive in php.ini.';
$string['errorpostmaxsize'] = 'The file you tried to upload is too large for the server to process.';
$string['errorwhilecommunicatingwith'] = 'Error while communicating with the repository \'{$a}\'.';
$string['errorwhiledownload'] = 'An error occurred while downloading the file: {$a}';
$string['existingrepository'] = 'This repository already exists';
Expand Down
11 changes: 8 additions & 3 deletions lib/form/dndupload.js
Expand Up @@ -876,7 +876,6 @@ M.form_dndupload.init = function(Y, options) {

// Prepare the data to send
var formdata = new FormData();
formdata.append('action', 'upload');
formdata.append('repo_upload_file', file); // The FormData class allows us to attach a file
formdata.append('sesskey', M.cfg.sesskey);
formdata.append('repo_id', this.repositoryid);
Expand Down Expand Up @@ -905,8 +904,14 @@ M.form_dndupload.init = function(Y, options) {
formdata.append('accepted_types[]', this.options.acceptedtypes);
}

// Send the file & required details
xhr.open("POST", this.api, true);
// Send the file & required details.
var uploadUrl = this.api;
if (uploadUrl.indexOf('?') !== -1) {
uploadUrl += '&action=upload';
} else {
uploadUrl += '?action=upload';
}
xhr.open("POST", uploadUrl, true);
xhr.send(formdata);
return true;
}
Expand Down

0 comments on commit 658a922

Please sign in to comment.