catch exceptions while uploading and pass on the error message

This commit is contained in:
Thomas Müller 2013-10-08 15:03:24 +02:00
parent 730c80ff9c
commit 7c6ed6ab33
2 changed files with 29 additions and 24 deletions

View File

@ -110,6 +110,8 @@ if (strpos($dir, '..') === false) {
|| (isset($_POST['resolution']) && $_POST['resolution']==='replace')
) {
// upload and overwrite file
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
@ -135,6 +137,9 @@ if (strpos($dir, '..') === false) {
} else {
$error = $l->t('Upload failed. Could not find uploaded file');
}
} catch(Exception $ex) {
$error = $ex->getMessage();
}
} else {
// file already exists
@ -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))));
}

View File

@ -365,7 +365,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);
}