summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/files/ajax/upload.php26
-rw-r--r--apps/files/js/file-upload.js3
-rw-r--r--apps/files/js/filelist.js32
3 files changed, 48 insertions, 13 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index 145f40c50da..b2aa7a99200 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -103,22 +103,32 @@ if ($maxUploadFileSize >= 0 and $totalSize > $maxUploadFileSize) {
}
$result = array();
+$directory = '';
if (strpos($dir, '..') === false) {
$fileCount = count($files['name']);
for ($i = 0; $i < $fileCount; $i++) {
+
+ // Get the files directory
+ if(isset($_POST['file_directory']) === true) {
+ $directory = '/'.$_POST['file_directory'];
+ }
+
// $path needs to be normalized - this failed within drag'n'drop upload to a sub-folder
if (isset($_POST['resolution']) && $_POST['resolution']==='autorename') {
// append a number in brackets like 'filename (2).ext'
- $target = OCP\Files::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]);
+ $target = OCP\Files::buildNotExistingFileName(stripslashes($dir.$directory), $files['name'][$i]);
} else {
- $target = \OC\Files\Filesystem::normalizePath(stripslashes($dir).'/'.$files['name'][$i]);
+ $target = \OC\Files\Filesystem::normalizePath(stripslashes($dir.$directory).'/'.$files['name'][$i]);
}
-
- $directory = \OC\Files\Filesystem::normalizePath(stripslashes($dir));
- if (isset($public_directory)) {
- // If we are uploading from the public app,
- // we want to send the relative path in the ajax request.
- $directory = $public_directory;
+
+ if(empty($directory) === true)
+ {
+ $directory = \OC\Files\Filesystem::normalizePath(stripslashes($dir));
+ if (isset($public_directory)) {
+ // If we are uploading from the public app,
+ // we want to send the relative path in the ajax request.
+ $directory = $public_directory;
+ }
}
if ( ! \OC\Files\Filesystem::file_exists($target)
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index f962a7044a8..ae6fdc654e4 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -327,7 +327,8 @@ $(document).ready(function() {
// noone set update parameters, we set the minimum
data.formData = {
requesttoken: oc_requesttoken,
- dir: $('#dir').val()
+ dir: $('#dir').val(),
+ file_directory: data.files[0]['relativePath'],
};
}
},
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index d6cffde05de..2631812c2e2 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -879,7 +879,8 @@ $(document).ready(function() {
data.formData = function(form) {
return [
{name: 'dir', value: dir},
- {name: 'requesttoken', value: oc_requesttoken}
+ {name: 'requesttoken', value: oc_requesttoken},
+ {name: 'file_directory', value: data.files[0]['relativePath']}
];
};
}
@@ -935,7 +936,7 @@ $(document).ready(function() {
var file = result[0];
if (data.context && data.context.data('type') === 'dir') {
-
+
// update upload counter ui
var uploadtext = data.context.find('.uploadtext');
var currentUploads = parseInt(uploadtext.attr('currentUploads'));
@@ -956,10 +957,33 @@ $(document).ready(function() {
size += parseInt(file.size);
data.context.attr('data-size', size);
data.context.find('td.filesize').text(humanFileSize(size));
-
- } else {
+ }
+ else {
+
// only append new file if uploaded into the current folder
if (file.directory !== FileList.getCurrentDirectory()) {
+
+ file_directory = file.directory.replace('/','').replace(/\/$/, "").split('/');
+
+ if (file_directory.length == 1) {
+ file_directory = file_directory[0];
+
+ // Get the directory
+ if ($('tr[data-file="'+file_directory+'"]').length == 0)
+ {
+ FileList.addDir(file_directory, 0, new Date(), false);
+ }
+ }
+ else {
+ file_directory = file_directory[0];
+ }
+
+ // update folder size
+ var size = parseInt($('tr[data-file="'+file_directory+'"]').attr('data-size'));
+ size += parseInt(file.size);
+ $('tr[data-file="'+file_directory+'"]').attr('data-size', size);
+ $('tr[data-file="'+file_directory+'"]').find('td.filesize').text(humanFileSize(size));
+
return;
}