I don't understand why loading from Laravel storage suddenly stopped working. Can you help me?

Viewed 42

I don't understand why loading from Laravel storage suddenly stopped working. Can you help me?

enter image description here

[![enter image description here][2]][2]

class PhotosController extends Controller {
public function create(int $albumId){
    return view('admin.photos.create')->with('albumId', $albumId);
}

public function store(Request $request){ 
    $this->validate($request, [
        'title' => 'required',
        'description' => 'required',
        'photo' => 'required|image'
    ]);

    $filenameWithExtension = $request->file('photo')->getClientOriginalName();
    $filename = pathinfo($filenameWithExtension, PATHINFO_FILENAME);
    $extension = $request->file('photo')->getClientOriginalExtension();
    $filenameToStore = $filename . '_' . time() . '.' . $extension;

    $request->file('photo')->storeAs('public/images/backend_images/photo_album/' . $request->input('album-id'), $filenameToStore);

    $photo = new Photo();
    $photo->title = $request->input('title');
    $photo->description = $request->input('description');
    $photo->photo = $filenameToStore;
    $photo->size = $request->file('photo')->getSize();
    $photo->album_id = $request->input('album-id');
    $photo->save();

    return redirect('/admin/showphoto/' . $request->input('album-id'))->with('flash_message_success','Foto Aggiunta Con Successo!');
    }

    public function destroy($id) {
        $photo = Photo::find($id);

        if (Storage::delete('public/images/backend_images/photo_album/' .$photo->album_id.'/'.$photo->photo)) {
            $photo->delete();
            return redirect('/admin/view-albums')->with('flash_message_success','Foto Eliminata Con Successo!');
        }

    }
}

This is the error in DevTools -> Failed to load resource: the server responded with a status of 404 (Not Found)

0 Answers
Related