I am having an issue with livewire on uploading files. I am using a very basic example to achieve my goal but the issue is that it returns null on Submit.
Here is my Livewire controller Code:
class UploadPhoto extends Component
{
use WithFileUploads;
public $photo;
public function save()
{
dd($this->photo); //returns null
$this->validate([
'photo' => 'image|max:1024', // 1MB Max
]);
$this->photo->store('photos');
}
}
<form wire:submit.prevent="save">
<input type="file" wire:model="photo">
@error('photo') <span class="error">{{ $message }}</span> @enderror
<button type="submit">Save Photo</button>
</form>