diff --git a/files/ajax/upload.php b/files/ajax/upload.php index 0939ad0d097..effee0c03c1 100644 --- a/files/ajax/upload.php +++ b/files/ajax/upload.php @@ -21,7 +21,7 @@ if(!empty($dir)) $dir .= '/'; $target='/' . stripslashes($dir) . $fileName; if(strpos($dir,'..') === false){ if(OC_FILESYSTEM::fromUploadedFile($source,$target)){ - echo json_encode(array( "status" => "success")); + echo json_encode(array( "status" => "success", 'mime'=>OC_FILESYSTEM::getMimeType($target),'size'=>OC_FILESYSTEM::filesize($target))); exit(); } } diff --git a/files/js/files.js b/files/js/files.js index 2e95a7881ef..0172ab1b1a9 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -127,13 +127,21 @@ $(document).ready(function() { }) $('#file_upload_submit').click(function(){ - $('#file_upload_form').submit(); var name=$('#file_upload_filename').val(); if($('#file_upload_start')[0].files[0] && $('#file_upload_start')[0].files[0].size>0){ var size=humanFileSize($('#file_upload_start')[0].files[0].size); }else{ var size='Pending'; } + $('#file_upload_target').load(function(){ + var response=jQuery.parseJSON($('#file_upload_target').contents().find('body').text()); + //set mimetype and if needed filesize + $('tr[data-file="'+name+'"]').attr('data-mime',response.mime); + if(size=='Pending'){ + $('tr[data-file='+name+'] td.filesize').text(response.size); + } + }); + $('#file_upload_form').submit(); var date=new Date(); var uploadTime=formatDate(date); FileList.addFile(name,size,uploadTime);