Neeraj1005
5 months ago
833
1
Laravel

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

Posted 5 months ago by Neeraj1005

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');
    }

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