Image source not readable in Laravel 5.2 - Intervention Image

前端 未结 6 1703
孤独总比滥情好
孤独总比滥情好 2021-02-07 18:27

I have a small problem concerning the resizing process of a given image, I am trying to submit a form containing an input type -->file<-- I was able to upload a picture witho

6条回答
  •  心在旅途
    2021-02-07 18:59

    In L5.2 its not directly possible to get image from Input facade. For that we need to first store the image on server and then give path into Image facade to do operations on image.

    Code goes likes this:

    if ($request->hasFile('picture') ) {
    
            $destinationPath = public_path('uploads/user');
            $photoname = date("YmdHis");
            $file_extention = '.'.$request->file('picture')->getClientOriginalExtension();
            $photo = $photoname.$file_extention;
            $file_check = $request->file('picture')->move($destinationPath, $photo);
    
            $thumb_path = $destinationPath.'/thumbnail/'.$photo;
    
            $new_filePath =  $destinationPath.'/'.$photo;
    
            $assets_path = url('uploads/user/');
    
            $img = Image::make($assets_path.'/'.$photo)->fit(100)->save($thumb_path,40);
    
            $data['picture'] = $photo;           
        }
    

    I was looking for direct solution i.e. as it was possible previously to take image directly from Input facade. If anyone of you have direct solution, show your code here and I'll reward you this bounty. Cheers.

提交回复
热议问题