I started learning Laravel 9 livewire. I am trying to make an image upload application. I did the exact example in the Livewire documentation, but I get an error that the image could not be uploaded. When I do the same application on my mac computer, it works without any problems. It doesn’t work when I do it on my windows computer.
ImageUpload.php
<?php
namespace AppHttpLivewire;
use LivewireComponent;
use LivewireWithFileUploads;
class ImegaUpload extends Component
{
use WithFileUploads;
public $photo;
public function save()
{
$this->validate([
'photo' => 'image|max:1024', // 1MB Max
]);
$this->photo->store('photos');
}
public function render()
{
return view('livewire.imega-upload');
}
}
image-upload.blade.php
<div>
<h1>Image upload</h1>
<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>
</div>
I’m doing the example in the Livewire documentation but still getting the error. Not even the livewire-temp folder is created.
2
Answers
Look like your PHP.ini is missing
and
uncomment and then set its value.
mine example.
Laragon on win 10:
all temp files will go to that location (not just uploaded)
In
AppHttpMiddlewareTrustProxies
change
protected $proxies;
to
protected $proxies = '*';
it helped me