How to know the mime and the originalName of a file with a FileUpload

Hi, How can I know the mime and the originalName of a file with a FileUpload? It is a bulkaction that calls a modal with a form, and I want to send the file by mail. I leave my code: ->form([ Forms\Components\TextInput::make('asunto')->required(), RichEditor::make('cuerpo')->required(), Forms\Components\FileUpload::make('attachments') ->label('Adjunto') ->acceptedFileTypes(['application/pdf','application/msword', 'image/jpg', 'image/png']) ->multiple() ->getUploadedFileNameForStorageUsing(function (TemporaryUploadedFile $file): string { return (string) str($file->getClientOriginalName())->prepend('file-'); }) ->disk('private') ->directory(function () {return 'emails-alumnos/'.now()->format('d-m-Y');}) ])->requiresConfirmation(),
4 Replies
Dan Harrin
Dan Harrin2y ago
i think there is a preserveOriginalFileNames() method or similar to prevent you needing getUploadedFileNameForStorageUsing()
astronomic
astronomicOP2y ago
Thank you! but in the end I searched for the file with storage and now I can recover the originalName and the mime.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
astronomic
astronomicOP2y ago
Hi @castellani9 , I do with: if (Storage::exists('private/'.$file)) { $originalName= basename('private/'.$file); $mimeType = Storage::mimeType('private/'.$file); $message->attach('../storage/app/private/'.$file, [ 'as' => $originalName, 'mime' => $mimeType, ]);
Want results from more Discord servers?
Add your server