diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2013-10-11 10:35:17 -0700 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2013-10-11 10:35:17 -0700 |
commit | dc58195c7faff0285e9d4dea038331411d49dd1c (patch) | |
tree | 0a0bd49dc04b53f5e4e4e3e65e761419607692db /apps | |
parent | 067475a9071753d018f48cb42cb78d5baa13f0fc (diff) | |
parent | 3f27fefdbe1342701161bf0949dd719f34dab76d (diff) | |
download | nextcloud-server-dc58195c7faff0285e9d4dea038331411d49dd1c.tar.gz nextcloud-server-dc58195c7faff0285e9d4dea038331411d49dd1c.zip |
Merge pull request #5207 from owncloud/fixing-4011-part2-master
[OC6] file upload exception handling
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/ajax/upload.php | 51 | ||||
-rw-r--r-- | apps/files/js/file-upload.js | 2 |
2 files changed, 29 insertions, 24 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index 0920bf62109..45fb17de94a 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -110,30 +110,35 @@ if (strpos($dir, '..') === false) { || (isset($_POST['resolution']) && $_POST['resolution']==='replace') ) { // upload and overwrite file - if (is_uploaded_file($files['tmp_name'][$i]) and \OC\Files\Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) { - - // updated max file size after upload - $storageStats = \OCA\Files\Helper::buildFileStorageStatistics($dir); - - $meta = \OC\Files\Filesystem::getFileInfo($target); - if ($meta === false) { - $error = $l->t('Upload failed. Could not get file info.'); + try + { + if (is_uploaded_file($files['tmp_name'][$i]) and \OC\Files\Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) { + + // updated max file size after upload + $storageStats = \OCA\Files\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, + 'permissions' => $meta['permissions'], + ); + } + } 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, - 'permissions' => $meta['permissions'], - ); + $error = $l->t('Upload failed. Could not find uploaded file'); } - - } else { - $error = $l->t('Upload failed. Could not find uploaded file'); + } catch(Exception $ex) { + $error = $ex->getMessage(); } } else { @@ -164,5 +169,5 @@ if ($error === false) { OCP\JSON::encodedPrint($result); exit(); } else { - OCP\JSON::error(array('data' => array_merge(array('message' => $error), $storageStats))); + OCP\JSON::error(array(array('data' => array_merge(array('message' => $error), $storageStats)))); } diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index fbb53b3530a..c03e9037cec 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -345,7 +345,7 @@ $(document).ready(function() { } else if (result[0].status !== 'success') { //delete data.jqXHR; data.textStatus = 'servererror'; - data.errorThrown = result.data.message; // error message has been translated on server + data.errorThrown = result[0].data.message; // error message has been translated on server var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload'); fu._trigger('fail', e, data); } |