Search code examples
phplaravelimagefile-uploadintervention

Laravel 10 Image source not readable


I want to upload an image on my app, but when I do that, I have this error "image source not readable". I checked the file path and name, all fine. I've linked the folders, but I don't know where the issue comes from. Few days ago its was working

    $imagePath = request('image')->store('uploads', 'public');
    $image = Image::make(public_path("/storage/app/{$imagePath}"))->fit(1200, 1200);
    $image->save();

    auth()->user()->ads()->create([
        'image' => $imagePath
    ]);

and my form looks like below

<form method="POST" action="{{ route('store') }}" enctype="multipart/form-data">
 <div class="form-group">
<div class="custom-file">
  <input type="file" name="image" class="custom-file-input @error('image') is-invalid @enderror" id="validatedCustomFile">
     <label class="custom-file-label" for="validatedCustomFile">Choisir une image</label>
       @error('image')
      <span class="invalid-feedback" role="alert">
     <strong>{{ $message }}</strong></span>
       @enderror
  </div>

Solution

  • Make sure that the "storage/app" directory and its subdirectories have appropriate permissions that allow the server to read and write.

    chmod -R 755 storage
    chmod -R 755 public/storage