xpk123@gmail.com's avatar

The photo failed to upload ! Console POST 500 (internal Server Error)

Hi, i am new to livewire. I am just following docs. https://laravel-livewire.com/docs/2.x/file-uploads where i have made basic file upload. as below

UploadPhoto.php

namespace App\Http\Livewire;

use Livewire\Component;
use Livewire\WithFileUploads;

class UploadPhoto 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.upload-photo');
    }
}

and blade file.

<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>

but when i am selecting file without submitting form i am getting error "The photo failed to upload" and in console i see POST http://laralive.test/livewire/upload-file?expires=1669637723&signature=c65fde13d14abf55dec3e81454040ccab1986fef5b811d5382b745d6320d233f 500 (Internal Server Error)

any idea what is going on?

Regards, Morty

0 likes
9 replies
Snapey's avatar

what is the document root of your website

Snapey's avatar

have you examined the 500 error in the log files?

1 like
xpk123@gmail.com's avatar

@Snapey Oh! I missed that. look like in php.ini sys_temp_dir and upload_tmp_dir was not set.

Thanks for pointing.

Jsloo's avatar

@xpk123@gmail.com Hii, i got the same issue, how do you solve it?

ZKYRIO's avatar

@xpk123@gmail.com How do you set up the php.ini file to solve this case?

Please or to participate in this conversation.