Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Aceboy76's avatar

Livewire image returns null

How to do i fix the image upload, it always returns null

<form wire:submit="save">

    @if ($photo)
        <img src="{{ $photo->temporaryUrl() }}">
    @endif

    <input type="file" wire:model="photo">

    @error('photo')
        <span class="error">{{ $message }}</span>
    @enderror

    <button type="submit">Save photo</button>

</form>

namespace App\Livewire\Pages;

use Livewire\Component;

use Livewire\WithFileUploads;

class TestPage extends Component{

use WithFileUploads;


public $photo;

public function render()
{
    return view('livewire.pages.test-page');
}



public function save()
{
    dd($this->photo);

    $this->validate([
        'photo' => 'image|mimes:jpg,png', // 1MB Max
    ]);

    $this->photo->store('photos');

}

}

0 likes
1 reply
migsAV's avatar

@aceboy76 what returns null? The $photo->temporaryUrl() or the dd($this->photo)

Please or to participate in this conversation.