Skip to content

Commit 7615204

Browse files
authored
Merge pull request #882 from okandas/master
ckeditor responses should be in json
2 parents 2372f39 + 63517a4 commit 7615204

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/Controllers/UploadController.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,23 @@ public function upload()
4343
}
4444

4545
if (is_array($uploaded_files)) {
46-
$response = count($error_bag) > 0 ? $error_bag : array(parent::$success_response);
47-
} else { // upload via ckeditor 'Upload' tab
46+
$response = count($error_bag) > 0 ? $error_bag : parent::$success_response;
47+
} else { // upload via ckeditor5 expects json responses
4848
if (is_null($new_filename)) {
49-
$response = $error_bag[0];
49+
$response = ['error' =>
50+
[
51+
'message' => $error_bag[0]
52+
]
53+
];
5054
} else {
51-
$response = view(Lfm::PACKAGE_NAME . '::use')
52-
->withFile($this->lfm->setName($new_filename)->url());
55+
$url = $this->lfm->setName($new_filename)->url();
56+
57+
$response = [
58+
'url' => $url
59+
];
5360
}
5461
}
5562

56-
return json_encode($response);
63+
return response()->json($response);
5764
}
5865
}

0 commit comments

Comments
 (0)