1use Livewire\WithFileUploads;
2
3class UploadPhoto extends Component
4{
5 use WithFileUploads;
6
7 public $photo;
8
9 public function save()
10 {
11 $this->validate([
12 'photo' => 'image|max:1024', // 1MB Max
13 ]);
14
15 $this->photo->store('photos');
16 }
17}
1<form wire:submit.prevent="save">
2 <input type="file" wire:model="photo">
3
4 @error('photo') <span class="error">{{ $message }}</span> @enderror
5
6 <button type="submit">Save Photo</button>
7</form>