Commit 640b642f authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 634193: Checking for too big file before form submit



This should be ok as if the file is too big for quota then it will be
complained about. If it is too big for post_max_size then will error out

behatnotneeded

Change-Id: I0b4fc8cd6bfad9c302299e1ea14a8180d427b3c6
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 1a81d018
......@@ -88,6 +88,7 @@ var FileBrowser = (function($) {
}
});
}
$('#' + self.id + '_userfile').off('change');
$('#' + self.id + '_userfile').on('change', self.upload_submit);
};
......@@ -100,7 +101,13 @@ var FileBrowser = (function($) {
this.upload_validate = function () {
if ($('#' + self.id + '_notice').length && !$('#' + self.id + '_notice').prop('checked')) {
$('#' + self.id+'_upload_messages').append($('<div>', {'class':'error'}), get_string('youmustagreetothecopyrightnotice'));
$('#' + self.id+'_upload_messages').append($('<div>', {'class':'alert alert-danger', 'text':get_string('youmustagreetothecopyrightnotice')}));
return false;
}
if (!($('#' + self.id + '_userfile')[0].files[0].size < globalconfig.maxuploadsize)) {
var errmsg = $('<div>', {'class':'alert alert-danger'});
errmsg.html(get_string_ajax('fileuploadtoobig', 'error', globalconfig.maxuploadsizepretty));
$('#' + self.id+'_upload_messages').append(errmsg);
return false;
}
return !$.isEmptyObject($('#' + self.id + '_userfile').val());
......@@ -152,6 +159,7 @@ var FileBrowser = (function($) {
'multiple':''
})
);
$('#' + self.id + '_userfile').off('change');
$('#' + self.id + '_userfile').on('change', self.upload_submit);
$('#' + self.id + '_upload').val(0);
return false;
......
......@@ -46,9 +46,7 @@ function get_string(name) {
* Getting the string via ajax as deferred object
*/
function get_string_ajax(str, section) {
// need to pass all the arguments except 'section' in case there are %s variables
var getstringargs = [str].concat([].slice.call(arguments, 2));
var getstringargs = Array.prototype.concat.apply([], arguments);
// If string already exists in strings object
if (typeof(strings[str]) !== 'undefined') {
return get_string.apply(this, getstringargs);
......
......@@ -155,3 +155,5 @@ $string['memcacheusememcached'] = 'The "memcache" session storage is obsolete. P
$string['siteoutofsyncfor'] = 'This site has database information newer than %s files indicate it should be.';
$string['updatesitetimezone'] = 'The time zone for the site now needs to be set via "Configure site" → "Site options" → "Site settings". Please set it there and delete the $cfg->dbtimezone line from your config.php file.';
$string['pluginnotactive1'] = 'The plugin "%s" is not enabled. Please got to "Administration" → "Extensions" → "Plugin administration" to enable it.';
$string['fileuploadtoobig'] = 'The file upload is too big as it is bigger than "%s"';
......@@ -660,6 +660,9 @@ EOF;
$headers = array_merge($headers, $select2headdata);
$smarty->assign('select2_language', $select2lang);
}
$maxuploadsize = get_max_upload_size(false);
$smarty->assign('maxuploadsize', $maxuploadsize);
$smarty->assign('maxuploadsizepretty', display_size($maxuploadsize));
$sitename = get_config('sitename');
if (!$sitename) {
......
......@@ -21,7 +21,9 @@
'handheld_device': {if $HANDHELD_DEVICE}1{else}0{/if},
'cc_enabled': {$CC_ENABLED|intval},
'mathjax': {ifconfig key=mathjax}1{else}0{/ifconfig},
'select2_lang': '{if $select2_language}{$select2_language}{/if}'
'select2_lang': '{if $select2_language}{$select2_language}{/if}',
'maxuploadsize': '{$maxuploadsize}',
'maxuploadsizepretty': '{$maxuploadsizepretty}'
{literal}}{/literal};
</script>
{$STRINGJS|safe}
......
Markdown is supported
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