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')
|
||||
) {
|
||||
// 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))));
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue