summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-11-16 07:46:50 -0800
committerBart Visscher <bartv@thisnet.nl>2012-11-16 07:46:50 -0800
commitb03eca5ee2f0197162aad2dcb607a7c663cdd558 (patch)
treeaa6a601a75a55952daa9141015504a550363da2b
parentd1c0f2a7393d82629bec961e056856846bd05465 (diff)
parent4a3b5125cfb4f35d8a40597aca200d0d37d494dd (diff)
downloadnextcloud-server-b03eca5ee2f0197162aad2dcb607a7c663cdd558.tar.gz
nextcloud-server-b03eca5ee2f0197162aad2dcb607a7c663cdd558.zip
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
-rw-r--r--apps/files/ajax/upload.php2
-rw-r--r--apps/files/js/filelist.js2
-rw-r--r--apps/files/js/files.js20
3 files changed, 20 insertions, 4 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index 4ed0bbc5b0f..c3d3199a003 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 f754a7cd162..a5550dc9926 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=$('<input class="filename"></input>').val(name);
+ input=$('<input class="filename"/>').val(name);
form=$('<form></form>');
form.append(input);
td.children('a.name').hide();
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index 982351c589e..bb80841055b 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;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]);