rjcc
rjcc
FFilament
Created by rjcc on 10/8/2024 in #❓┊help
Get chosen files on FileUpload (multiple) after state updated.
Hi guys. I want to get the chosen files to be uploaded (temporary files) after state updated. It actually works on single file upload but when it comes to multiple, it didn't work out. Can you help me solve this? Thanks in advance. FileUpload::make('file') ->label('Documents:') ->validationAttribute('documents') ->acceptedFileTypes(['application/pdf']) ->required() ->openable() ->multiple() ->downloadable(false) ->deletable(false) ->reorderable() ->appendFiles() ->preserveFilenames() ->uploadingMessage('Uploading Documents...') ->directory(fn ($get) => $get('number')) // Directory based on 'number' field ->reactive() ->afterStateUpdated(function (TemporaryUploadedFile $state, callable $set) { //dd($state); $set('filePreviewData', $state->getClientOriginalName()); }), ViewField::make('filePreviewData') ->view('livewire.file-preview-modal') ->visible(function ($get) { if ($get('file') !== null && !empty($get('file'))) { return $get('file'); } })
10 replies