summaryrefslogtreecommitdiffstats
path: root/apps/files/ajax/upload.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/ajax/upload.php')
-rw-r--r--apps/files/ajax/upload.php27
1 files changed, 18 insertions, 9 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index b21a9dfba2e..a5ce7b257da 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -111,22 +111,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)
@@ -186,7 +196,6 @@ if (strpos($dir, '..') === false) {
if ($error === false) {
OCP\JSON::encodedPrint($result);
- exit();
} else {
OCP\JSON::error(array(array('data' => array_merge(array('message' => $error, 'code' => $errorCode), $storageStats))));
}