Neeraj1005's avatar

ErrorException getimagesize(avatar/about.jpg): failed to open stream: No such file or directory

I am trying to get the width and height of file, but it gives me an error. And In Laravel is there any other method to get the width and height of an image using fileStorage? plz let me know

    public function store(Request $request)
    {
        $media = new Media();

        if ($request->hasFile('filename')){
            $avatar = $request->filename->getClientOriginalName();
            $fileextension = $request->filename->extension();
            $mime = $request->filename->getClientMimeType();
            $size = $request->filename->getSize();

            $upload = $request->filename->storeAs('avatar',$avatar,'public');
            $imagesize = getimagesize($upload);
            $width = $imagesize[0];
            $height = $imagesize[1];

            dd($width);
        }

        $media->filename = $avatar;
        $media->path = $upload;
        $media->size = $size;
        $media->mime = $mime;
        $media->extension = $fileextension;

        $media->save();

        return redirect()->back()->with('status','image uploaded successfully');
    }
0 likes
1 reply

Please or to participate in this conversation.