Skip to content

Commit b0a738b

Browse files
author
FreedomKnight
committed
讓 filemanager 有錯誤訊息
1 parent 376ad24 commit b0a738b

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

public/js/script.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ function performLfmRequest(url, parameter, type) {
129129
}
130130

131131
var refreshFoldersAndItems = function (data) {
132-
if (data == 'OK') {
133-
loadFolders();
134-
} else {
132+
loadFolders();
133+
if (data != 'OK') {
134+
data = Array.isArray(data) ? data.join('<br/>') : data;
135135
notify(data);
136136
}
137137
};

src/controllers/UploadController.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,22 @@ class UploadController extends LfmController
2727
public function upload()
2828
{
2929
$files = request()->file('upload');
30-
31-
if (is_array($files)) {
32-
foreach ($files as $file) {
33-
$this->proceedSingleUpload($file);
30+
$error_bag = [];
31+
foreach (is_array($files) ? $files : [$files] as $file) {
32+
$validation_message = $this->uploadValidator($file);
33+
$new_filename = $this->proceedSingleUpload($file);
34+
35+
if ($validation_message !== 'pass') {
36+
array_push($error_bag, $validation_message);
37+
} elseif ($new_filename == 'invalid') {
38+
array_push($error_bag, $response);
3439
}
3540

36-
$response = $this->success_response;
37-
} else { // upload via ckeditor 'Upload' tab
38-
$new_filename = $this->proceedSingleUpload($files);
41+
}
3942

43+
if (is_array($files)) {
44+
$response = count($error_bag) > 0 ? $error_bag : $this->success_response;
45+
} else { // upload via ckeditor 'Upload' tab
4046
$response = $this->useFile($new_filename);
4147
}
4248

0 commit comments

Comments
 (0)