I get error in image upload preview

I get this error in image upload preview while the same procedure in another package is ok:

Call to a member function temporaryUrl() on string

View:

  <div>
    @if($photo)
      <img src="{{ $photo->temporaryUrl() }}">
    @endif
    <input type="file" wire:model="photo">
  </div>

Class:

  use WithFileUploads;

  public $photo;

    public function render()
    {
        return view('livewire.coach-new');
    }

Do you get this error on first render or after you’ve uploaded a file? You may need a different blade if statement. Try:

@if ($photo->temporaryUrl() !== null)
    <img src="{{ $photo->temporaryUrl() }}">
@endif
1 Like

Thank you. I reinstalled the Laravel packages and replaced Models and … and the problem solved !