Merge pull request #471 from owncloud/461_drag_drop_upload_to_folder
refs #461 - drag'n'drop upload to a sub folder is working now
This commit is contained in:
commit
b03eca5ee2
|
@ -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);
|
||||
|
|
|
@ -141,7 +141,7 @@ var FileList={
|
|||
tr=$('tr').filterAttr('data-file',name);
|
||||
tr.data('renaming',true);
|
||||
td=tr.children('td.filename');
|
||||
input=$('<input class="filename"></input>').val(name);
|
||||
input=$('<input class="filename"/>').val(name);
|
||||
form=$('<form></form>');
|
||||
form.append(input);
|
||||
td.children('a.name').hide();
|
||||
|
|
|
@ -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;i<files.length;i++){
|
||||
if(files[i].size>0){
|
||||
|
@ -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]);
|
||||
|
|
Loading…
Reference in New Issue