So I have a Laravel app and for some reason Livewire isn't handling file uploads as per the documentation. This is causing me to be unable to save or validate the file in terms of size and/or mimetype.
I have copied the example provided in the documentation (https://laravel-livewire.com/docs/2.x/file-uploads) exactly (literally copy and pasted from the docs) and when I upload a file, I always get a Livewire/TemporaryUploadedFile instance which won't let me validate. In my actual app I need to restrict the filesize of uploaded files as well as the type (.wav, .ogg, .mp4)
For clarity, I'll copy the file contents from my files - but as I've said, I copy and pasted from the example given:
-- upload-photo.blade.php
<input type="file" wire:model="photo">
@error('photo') <span class="error">{{ $message }}</span> @enderror
<button type="submit">Save Photo</button>
</form>
-- UploadPhoto.php
<?php
namespace App\Http\Livewire;
use Livewire\Component;
use Livewire\WithFileUploads;
class UploadPhoto extends Component
{
use WithFileUploads;
public $photo;
public function updatedPhoto()
{
$this->validate([
'photo' => 'image|max:1024', // 1MB Max
]);
}
public function save()
{
dd($this->photo);
}
public function render()
{
return view('livewire.upload-photo');
}
}
I've also done a quick screencast to show how the realtime validation is failing to detect the file type: https://www.dropbox.com/s/5981v5gncdcwc7d/2022-03-23_21-25-06.mp4?dl=0
Any help would be appreaciated.
Thanks
Anthony
