show error when trying to upload to large files

This commit is contained in:
Robin Appelman 2011-07-22 15:48:30 +02:00
parent e6e14719c9
commit d6bf5cd251
3 changed files with 55 additions and 33 deletions

View File

@ -157,4 +157,5 @@ table td.delete { background-image:url('../img/delete.png'); }
#selectedActions{
float:right;
display:none;
}
}
#uploadsize-message{display:none}

View File

@ -153,40 +153,55 @@ $(document).ready(function() {
var uploadId=form.attr('data-upload-id');
var files=this.files;
var target=form.children('iframe');
target.load(function(){
var response=jQuery.parseJSON(target.contents().find('body').text());
//set mimetype and if needed filesize
if(response){
for(var i=0;i<response.length;i++){
var file=response[i];
$('tr[data-file="'+file.name+'"]').attr('data-mime',file.mime);
if(size=='Pending'){
$('tr[data-file='+file.name+'] td.filesize').text(file.size);
}
FileList.loadingDone(file.name);
}
}
});
form.submit();
var date=new Date();
var uploadTime=formatDate(date);
var totalSize=0;
for(var i=0;i<files.length;i++){
if(files[i].size>0){
var size=simpleFileSize(files[i].size);
}else{
var size='Pending';
}
FileList.addFile(files[i].name,size,uploadTime,true);
totalSize+=files[i].size;
}
if(totalSize>$('#max_upload').val()){
$( "#uploadsize-message" ).dialog({
modal: true,
buttons: {
Close: function() {
$( this ).dialog( "close" );
}
}
});
}else{
target.load(function(){
var response=jQuery.parseJSON(target.contents().find('body').text());
//set mimetype and if needed filesize
if(response){
for(var i=0;i<response.length;i++){
var file=response[i];
$('tr[data-file="'+file.name+'"]').attr('data-mime',file.mime);
if(size=='Pending'){
$('tr[data-file='+file.name+'] td.filesize').text(file.size);
}
FileList.loadingDone(file.name);
}
}
});
form.submit();
var date=new Date();
var uploadTime=formatDate(date);
for(var i=0;i<files.length;i++){
if(files[i].size>0){
var size=simpleFileSize(files[i].size);
}else{
var size='Pending';
}
FileList.addFile(files[i].name,size,uploadTime,true);
}
//clone the upload form and hide the new one to allow users to start a new upload while the old one is still uploading
var clone=form.clone();
uploadId++;
clone.attr('data-upload-id',uploadId);
clone.attr('target','file_upload_target_'+uploadId);
clone.children('iframe').attr('name','file_upload_target_'+uploadId)
clone.insertBefore(form);
form.hide();
}
//clone the upload form and hide the new one to allow users to start a new upload while the old one is still uploading
var clone=form.clone();
uploadId++;
clone.attr('data-upload-id',uploadId);
clone.attr('target','file_upload_target_'+uploadId);
clone.children('iframe').attr('name','file_upload_target_'+uploadId)
clone.insertBefore(form);
form.hide();
});
//add multiply file upload attribute to all browsers except konqueror (which crashes when it's used)

View File

@ -43,4 +43,10 @@
</tbody>
</table>
<div id="uploadsize-message" title="Upload to large">
<p>
<?php echo $l->t( 'The files you are trying to upload exceed the maximum size for file uploads on this server.' ); ?>
</p>
</div>
<span id="file_menu"/>