summaryrefslogtreecommitdiffstats
path: root/apps/files/ajax
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-10-08 15:03:24 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2013-10-08 15:03:24 +0200
commit7c6ed6ab33e8487d6de135b5e956a82685bf4463 (patch)
treec3e1156f734055e7fcae2916b7224dc340858c6f /apps/files/ajax
parent730c80ff9c83ff1b027ab804ecad599fbcaf7bd3 (diff)
downloadnextcloud-server-7c6ed6ab33e8487d6de135b5e956a82685bf4463.tar.gz
nextcloud-server-7c6ed6ab33e8487d6de135b5e956a82685bf4463.zip
catch exceptions while uploading and pass on the error message
Diffstat (limited to 'apps/files/ajax')
-rw-r--r--apps/files/ajax/upload.php51
1 files changed, 28 insertions, 23 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))));
}