summaryrefslogtreecommitdiffstats
path: root/apps/files/ajax
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2013-09-06 18:16:40 +0200
committerJörn Friedrich Dreyer <jfd@butonic.de>2013-09-06 18:16:40 +0200
commite2c0fe829698de9f89bf2cc3f854942f44bffc69 (patch)
tree72eb928d85a5353ec27d969ab31330d20b8ffad5 /apps/files/ajax
parent238d92b11cab31061fb5766b9f75d4772d48283e (diff)
downloadnextcloud-server-e2c0fe829698de9f89bf2cc3f854942f44bffc69.tar.gz
nextcloud-server-e2c0fe829698de9f89bf2cc3f854942f44bffc69.zip
fix upload of multiple files
Diffstat (limited to 'apps/files/ajax')
-rw-r--r--apps/files/ajax/upload.php61
1 files changed, 38 insertions, 23 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index 60c2454b290..12724c0c5bc 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -111,41 +111,56 @@ if (strpos($dir, '..') === false) {
) {
// upload and overwrite file
if (is_uploaded_file($files['tmp_name'][$i]) and \OC\Files\Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
- $status = 'success';
-
+
// updated max file size after upload
$storageStats = \OCA\files\lib\Helper::buildFileStorageStatistics($dir);
+ $meta = \OC\Files\Filesystem::getFileInfo($target);
+ if ($meta === false) {
+ $error = $l->t('Upload failed. Could not get file info.');
+ } else {
+ $result[] = array('status' => 'success',
+ 'mime' => $meta['mimetype'],
+ 'mtime' => $meta['mtime'],
+ 'size' => $meta['size'],
+ 'id' => $meta['fileid'],
+ 'name' => basename($target),
+ 'originalname' => $files['tmp_name'][$i],
+ 'uploadMaxFilesize' => $maxUploadFileSize,
+ 'maxHumanFilesize' => $maxHumanFileSize
+ );
+ }
+
} else {
$error = $l->t('Upload failed. Could not find uploaded file');
}
} else {
// file already exists
- $status = 'existserror';
- }
- }
- if ($error === false) {
- $meta = \OC\Files\Filesystem::getFileInfo($target);
- if ($meta === false) {
- $error = $l->t('Upload failed. Could not get file info.');
- } else {
- $result[] = array('status' => $status,
- 'mime' => $meta['mimetype'],
- 'mtime' => $meta['mtime'],
- 'size' => $meta['size'],
- 'id' => $meta['fileid'],
- 'name' => basename($target),
- 'originalname' => $files['tmp_name'][$i],
- 'uploadMaxFilesize' => $maxUploadFileSize,
- 'maxHumanFilesize' => $maxHumanFileSize
- );
- OCP\JSON::encodedPrint($result);
- exit();
+ $meta = \OC\Files\Filesystem::getFileInfo($target);
+ if ($meta === false) {
+ $error = $l->t('Upload failed. Could not get file info.');
+ } else {
+ $result[] = array('status' => 'existserror',
+ 'mime' => $meta['mimetype'],
+ 'mtime' => $meta['mtime'],
+ 'size' => $meta['size'],
+ 'id' => $meta['fileid'],
+ 'name' => basename($target),
+ 'originalname' => $files['tmp_name'][$i],
+ 'uploadMaxFilesize' => $maxUploadFileSize,
+ 'maxHumanFilesize' => $maxHumanFileSize
+ );
+ }
}
}
} else {
$error = $l->t('Invalid directory.');
}
-OCP\JSON::error(array('data' => array_merge(array('message' => $error), $storageStats)));
+if ($error === false) {
+ OCP\JSON::encodedPrint($result);
+ exit();
+} else {
+ OCP\JSON::error(array('data' => array_merge(array('message' => $error), $storageStats)));
+}