summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-08-08 15:58:57 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2013-08-08 15:58:57 +0200
commitd9d0a6e7d60084bdf7da5f270fa8587fc6d1aa91 (patch)
treef8e4c19ded1fcfaa1097306b254aeaaef0554e4f /apps
parent604ba1d0f71e81c3d10c8287df6ad22f1a94f1a7 (diff)
downloadnextcloud-server-d9d0a6e7d60084bdf7da5f270fa8587fc6d1aa91.tar.gz
nextcloud-server-d9d0a6e7d60084bdf7da5f270fa8587fc6d1aa91.zip
proper response in case the upload fails - e.g. in case permissions on shared folders are not enough
Diffstat (limited to 'apps')
-rw-r--r--apps/files/ajax/upload.php25
-rw-r--r--apps/files/js/file-upload.js55
2 files changed, 41 insertions, 39 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index 3ba3665bf3b..e2c6f73f862 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -102,18 +102,23 @@ if (strpos($dir, '..') === false) {
$target = \OC\Files\Filesystem::normalizePath($target);
if (is_uploaded_file($files['tmp_name'][$i]) and \OC\Files\Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
$meta = \OC\Files\Filesystem::getFileInfo($target);
+
// updated max file size after upload
$storageStats = \OCA\files\lib\Helper::buildFileStorageStatistics($dir);
-
- $result[] = array('status' => 'success',
- 'mime' => $meta['mimetype'],
- 'size' => $meta['size'],
- 'id' => $meta['fileid'],
- 'name' => basename($target),
- 'originalname' => $files['name'][$i],
- 'uploadMaxFilesize' => $maxUploadFileSize,
- 'maxHumanFilesize' => $maxHumanFileSize
- );
+ if ($meta === false) {
+ OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Upload failed')), $storageStats)));
+ exit();
+ } else {
+ $result[] = array('status' => 'success',
+ 'mime' => $meta['mimetype'],
+ 'size' => $meta['size'],
+ 'id' => $meta['fileid'],
+ 'name' => basename($target),
+ 'originalname' => $files['name'][$i],
+ 'uploadMaxFilesize' => $maxUploadFileSize,
+ 'maxHumanFilesize' => $maxHumanFileSize
+ );
+ }
}
}
OCP\JSON::encodedPrint($result);
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index 942a07dfccc..142704ee0be 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -91,38 +91,35 @@ $(document).ready(function() {
* @param data
*/
done:function(e, data) {
- // handle different responses (json or body from iframe for ie)
- var response;
- if (typeof data.result === 'string') {
- response = data.result;
- } else {
- //fetch response from iframe
- response = data.result[0].body.innerText;
- }
- var result=$.parseJSON(response);
-
- if(typeof result[0] !== 'undefined' && result[0].status === 'success') {
- var file = result[0];
- } else {
- data.textStatus = 'servererror';
- data.errorThrown = t('files', result.data.message);
- var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');
- fu._trigger('fail', e, data);
- }
+ // handle different responses (json or body from iframe for ie)
+ var response;
+ if (typeof data.result === 'string') {
+ response = data.result;
+ } else {
+ //fetch response from iframe
+ response = data.result[0].body.innerText;
+ }
+ var result=$.parseJSON(response);
- var filename = result[0].originalname;
+ if(typeof result[0] !== 'undefined' && result[0].status === 'success') {
+ var filename = result[0].originalname;
- // delete jqXHR reference
- if (typeof data.context !== 'undefined' && data.context.data('type') === 'dir') {
- var dirName = data.context.data('file');
- delete uploadingFiles[dirName][filename];
- if ($.assocArraySize(uploadingFiles[dirName]) == 0) {
- delete uploadingFiles[dirName];
+ // delete jqXHR reference
+ if (typeof data.context !== 'undefined' && data.context.data('type') === 'dir') {
+ var dirName = data.context.data('file');
+ delete uploadingFiles[dirName][filename];
+ if ($.assocArraySize(uploadingFiles[dirName]) == 0) {
+ delete uploadingFiles[dirName];
+ }
+ } else {
+ delete uploadingFiles[filename];
+ }
+ } else {
+ data.textStatus = 'servererror';
+ data.errorThrown = t('files', result.data.message);
+ var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');
+ fu._trigger('fail', e, data);
}
- } else {
- delete uploadingFiles[filename];
- }
-
},
/**
* called after last upload