nhayder
7 months ago

Can't write image data to path

Posted 7 months ago by nhayder

i'm using image intervention ti create thumbnails for images on my app, but i'm getting this error every time i try to save the thumbnail on target folder

when new images is loaded im creating a folder with main image and its thumbnail included in that new folder

    public function uploadphotos(Request $request)
    {
        
        $request->validate([

            'file' => 'required|image|mimes:jpeg,png,jpg,gif|max:50000',

        ]);
        
        $image = new Cloudfolder();
        
        $fileName = time()."-".$request['file']->getClientOriginalName();

        $image->uuid = (string) Str::uuid();
        $image->name = strtolower($fileName);
        $image->type = 'image';
        $image->downloads = 0;
        $image->user_id = Auth::id();
        $image->save();

        // Store file on cloudfolder
        Storage::makeDirectory('cloudfolder/'.$image->id); 

        $request->file->storeAs('cloudfolder/'.$image->id.'/', $fileName); // this saves the original file 

        // creating the thumbnail

        image::make($request->file)

            ->fit(50, 50, null, 'center')

            ->save(Storage::url('app/cloudfolder/'.$image->id.'/'.'sm-'.$fileName));
        
    }

this is the error im getting form the implementation above

    "message": "Can't write image data to path (/storage/app/cloudfolder/98/sm-1551295253-img-two.jpg)",

Please sign in or create an account to participate in this conversation.