summaryrefslogtreecommitdiffstats
path: root/apps/files/ajax
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-02-12 11:43:34 +0100
committerJoas Schilling <nickvergessen@gmx.de>2014-02-12 15:49:09 +0100
commit9619459e37dce3723eb912e1ea9f149dc3f5de49 (patch)
treedf23756455c298e3467a2dde7c9b2ecf42ae545b /apps/files/ajax
parent3699728a3a02dd17ea617a7e8f781c09e837f360 (diff)
downloadnextcloud-server-9619459e37dce3723eb912e1ea9f149dc3f5de49.tar.gz
nextcloud-server-9619459e37dce3723eb912e1ea9f149dc3f5de49.zip
Send correct path on file upload when using public app
Fix issue #7152
Diffstat (limited to 'apps/files/ajax')
-rw-r--r--apps/files/ajax/upload.php16
1 files changed, 12 insertions, 4 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index 754c34ef088..145f40c50da 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -22,6 +22,7 @@ if (empty($_POST['dirToken'])) {
} else {
// return only read permissions for public upload
$allowedPermissions = OCP\PERMISSION_READ;
+ $public_directory = !empty($_POST['subdir']) ? $_POST['subdir'] : '/';
$linkItem = OCP\Share::getShareByToken($_POST['dirToken']);
if ($linkItem === false) {
@@ -45,7 +46,7 @@ if (empty($_POST['dirToken'])) {
$dir = sprintf(
"/%s/%s",
$path,
- isset($_POST['subdir']) ? $_POST['subdir'] : ''
+ $public_directory
);
if (!$dir || empty($dir) || $dir === false) {
@@ -112,7 +113,14 @@ if (strpos($dir, '..') === false) {
} else {
$target = \OC\Files\Filesystem::normalizePath(stripslashes($dir).'/'.$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 ( ! \OC\Files\Filesystem::file_exists($target)
|| (isset($_POST['resolution']) && $_POST['resolution']==='replace')
) {
@@ -140,7 +148,7 @@ if (strpos($dir, '..') === false) {
'uploadMaxFilesize' => $maxUploadFileSize,
'maxHumanFilesize' => $maxHumanFileSize,
'permissions' => $meta['permissions'] & $allowedPermissions,
- 'directory' => \OC\Files\Filesystem::normalizePath(stripslashes($dir)),
+ 'directory' => $directory,
);
}
@@ -168,7 +176,7 @@ if (strpos($dir, '..') === false) {
'uploadMaxFilesize' => $maxUploadFileSize,
'maxHumanFilesize' => $maxHumanFileSize,
'permissions' => $meta['permissions'] & $allowedPermissions,
- 'directory' => \OC\Files\Filesystem::normalizePath(stripslashes($dir)),
+ 'directory' => $directory,
);
}
}