File upload without form tag

when File Upload need, we have to use form tag .

Following is from doc.


<form wire:submit.prevent="save">
        <input name="photo" type="file" wire:model="photo">
        @error('photo') <span class="error">{{ $message }}</span> @enderror
        <button wire:click="save">Save Photo</button>
    </form>

But we can not use double form ( another form inside form ). So I want to use file upload without ‘form’ tag for file upload.

I want enclose whole inputs with outside form and I can not use another form for file upload .

please look at my whole form …

<form action method>
<input type="text" name=title >

<livewire:file-upload /> // -->  file upload livewire component

<button type=submit > Submit </button>
</form>

How can we use file upload livewire component without ‘form’ tag ?

Hey @bingglex,

simply leave it out. You don’t have to use a form.

Can you show some code ?

Without form tag , submitting photo will not work. I guess.

Hey @bingglex,

    <input name="photo" type="file" wire:model="photo">
    @error('photo') <span class="error">{{ $message }}</span> @enderror
    <button wire:click="save">Save Photo</button>

Simple as that :smiley:

1 Like

Oh… Thanks…

I got how to make it up.

And I guess, I’d better add onChange event on Input tag.

Thanks.