diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index 4ed0bbc5b0..c3d3199a00 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -48,6 +48,8 @@ if(strpos($dir, '..') === false) { $fileCount=count($files['name']); for($i=0;$i<$fileCount;$i++) { $target = OCP\Files::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]); + // $path needs to be normalized - this failed within drag'n'drop upload to a sub-folder + $target = OC_Filesystem::normalizePath($target); if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) { $meta = OC_FileCache::get($target); $id = OC_FileCache::getId($target); diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index f754a7cd16..a5550dc992 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -141,7 +141,7 @@ var FileList={ tr=$('tr').filterAttr('data-file',name); tr.data('renaming',true); td=tr.children('td.filename'); - input=$('').val(name); + input=$('').val(name); form=$('
'); form.append(input); td.children('a.name').hide(); diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 982351c589..bb80841055 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -228,7 +228,12 @@ $(document).ready(function() { } }); }else{ - var date=new Date(); + var dropTarget = $(e.originalEvent.target).closest('tr'); + if(dropTarget && dropTarget.attr('data-type') === 'dir') { // drag&drop upload to folder + var dirName = dropTarget.attr('data-file') + } + + var date=new Date(); if(files){ for(var i=0;i0){ @@ -281,7 +286,10 @@ $(document).ready(function() { var jqXHR = $('.file_upload_start').fileupload('send', {files: files[i], formData: function(form) { var formArray = form.serializeArray(); - formArray[1]['value'] = dirName; + // array index 0 contains the max files size + // array index 1 contains the request token + // array index 2 contains the directory + formArray[2]['value'] = dirName; return formArray; }}).success(function(result, textStatus, jqXHR) { var response; @@ -291,7 +299,13 @@ $(document).ready(function() { $('#notification').fadeIn(); } var file=response[0]; + // TODO: this doesn't work if the file name has been changed server side delete uploadingFiles[dirName][file.name]; + if ($.assocArraySize(uploadingFiles[dirName]) == 0) { + delete uploadingFiles[dirName]; + } + + var uploadtext = $('tr').filterAttr('data-type', 'dir').filterAttr('data-file', dirName).find('.uploadtext') var currentUploads = parseInt(uploadtext.attr('currentUploads')); currentUploads -= 1; uploadtext.attr('currentUploads', currentUploads); @@ -821,7 +835,7 @@ function getSelectedFiles(property){ name:$(element).attr('data-file'), mime:$(element).data('mime'), type:$(element).data('type'), - size:$(element).data('size'), + size:$(element).data('size') }; if(property){ files.push(file[property]);