mardi 10 août 2021

How to display file names BEFORE submit in laravel?

I want to see the names of each file I uploaded to the form before clicking the submit button and with the option to remove it if I want, how do I do this in laravel? i'm using laravel 8

View:

<div class="mb-3">
   <label for="formFileMultiple" class="form-label" >Receita</label>
   <input class="form-control" type="file" id="formFileMultiple" name="files[]" multiple>
</div>

Controller:

 foreach ($request->file('files') as  $files) {
            Document::create([
                'COD_TIPO_DOCUMENTO'    => 1,
                'NOME_DOCUMENTO'        => $files->getClientOriginalName(),
                'DS_CAMINHO_DOCUMENTO'  => $files->store('orders'),
                'DT_CADASTRO'           => Carbon::now(),
                'NOME_EXTENSAO'         => $files->getClientOriginalExtension(),
                'DS_MIME_TYPE'          => $files->getClientMimeType()
            ]);
        }

Prototype: [1]: https://i.stack.imgur.com/ggxSi.png



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire