catch exceptions while uploading and pass on the error message
This commit is contained in:
parent
730c80ff9c
commit
7c6ed6ab33
|
@ -110,6 +110,8 @@ if (strpos($dir, '..') === false) {
|
||||||
|| (isset($_POST['resolution']) && $_POST['resolution']==='replace')
|
|| (isset($_POST['resolution']) && $_POST['resolution']==='replace')
|
||||||
) {
|
) {
|
||||||
// upload and overwrite file
|
// upload and overwrite file
|
||||||
|
try
|
||||||
|
{
|
||||||
if (is_uploaded_file($files['tmp_name'][$i]) and \OC\Files\Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
|
if (is_uploaded_file($files['tmp_name'][$i]) and \OC\Files\Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
|
||||||
|
|
||||||
// updated max file size after upload
|
// updated max file size after upload
|
||||||
|
@ -135,6 +137,9 @@ if (strpos($dir, '..') === false) {
|
||||||
} else {
|
} else {
|
||||||
$error = $l->t('Upload failed. Could not find uploaded file');
|
$error = $l->t('Upload failed. Could not find uploaded file');
|
||||||
}
|
}
|
||||||
|
} catch(Exception $ex) {
|
||||||
|
$error = $ex->getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// file already exists
|
// file already exists
|
||||||
|
@ -164,5 +169,5 @@ if ($error === false) {
|
||||||
OCP\JSON::encodedPrint($result);
|
OCP\JSON::encodedPrint($result);
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
OCP\JSON::error(array('data' => array_merge(array('message' => $error), $storageStats)));
|
OCP\JSON::error(array(array('data' => array_merge(array('message' => $error), $storageStats))));
|
||||||
}
|
}
|
||||||
|
|
|
@ -365,7 +365,7 @@ $(document).ready(function() {
|
||||||
} else if (result[0].status !== 'success') {
|
} else if (result[0].status !== 'success') {
|
||||||
//delete data.jqXHR;
|
//delete data.jqXHR;
|
||||||
data.textStatus = 'servererror';
|
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');
|
var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');
|
||||||
fu._trigger('fail', e, data);
|
fu._trigger('fail', e, data);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue