Skip to content

Commit 6854c29

Browse files
authored
Dropzone uploadMultiple: true error fix
When you set Dropzone.options.uploadForm.uploadMultiple : true in config of an instance of dropzone 5.7.2 the request is created by dropzone creates multidimensional input of the upload like below; upload[][0]: (binary) upload[][1]: (binary) upload[][2]: (binary) When you send this request it is trying to validate this array values which is already array in UniSharp\LaravelFilemanager::uploadValidator() but it is not a instance of UploadedFile it is instance of array. So with flatting this array we convert request array to a single dimension array like below; upload[0]: (binary) upload[1]: (binary) upload[2]: (binary)
1 parent 7f07972 commit 6854c29

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Controllers/UploadController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use UniSharp\LaravelFilemanager\Events\ImageIsUploading;
77
use UniSharp\LaravelFilemanager\Events\ImageWasUploaded;
88
use UniSharp\LaravelFilemanager\Lfm;
9+
use Illuminate\Support\Arr;
910

1011
class UploadController extends LfmController
1112
{
@@ -29,7 +30,7 @@ public function upload()
2930
$error_bag = [];
3031
$new_filename = null;
3132

32-
foreach (is_array($uploaded_files) ? $uploaded_files : [$uploaded_files] as $file) {
33+
foreach (is_array($uploaded_files) ? Arr::flatten($uploaded_files) : [$uploaded_files] as $file) {
3334
try {
3435
$new_filename = $this->lfm->upload($file);
3536
} catch (\Exception $e) {

0 commit comments

Comments
 (0)