Skip to content

Fix show the reason for not uploading the file #389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/FileManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,8 @@ public function tree($disk, $path): array
*
* @return array
*/
public function upload($disk, $path, $files, $overwrite): array
{
$fileNotUploaded = false;

$fileNotUploaded = false;
$notUploadedReason = "";
foreach ($files as $file) {
// skip or overwrite files
if (!$overwrite && Storage::disk($disk)->exists($path . '/' . $file->getClientOriginalName())) {
Expand All @@ -153,6 +151,7 @@ public function upload($disk, $path, $files, $overwrite): array
&& $file->getSize() / 1024 > $this->configRepository->getMaxUploadFileSize()
) {
$fileNotUploaded = true;
$notUploadedReason = "file is too large";
continue;
}

Expand All @@ -164,6 +163,7 @@ public function upload($disk, $path, $files, $overwrite): array
)
) {
$fileNotUploaded = true;
$notUploadedReason = "file type is not allowed";
continue;
}

Expand All @@ -189,7 +189,7 @@ public function upload($disk, $path, $files, $overwrite): array
return [
'result' => [
'status' => 'warning',
'message' => 'notAllUploaded',
'message' => $notUploadedReason,
],
];
}
Expand Down