Image Intervention w/ Laravel 5.4 Storage

后端 未结 10 867
执笔经年
执笔经年 2021-02-05 03:16

I\'m using the storage facade to store a avatar which works fine, but I want to resize my image like I did in previous versions of laravel. How can I go about doing this? Here i

10条回答
  •  春和景丽
    2021-02-05 03:41

    I've done it with following way, its simple and without any path confusion :

    //Get file
    $path= $request->file('createcommunityavatar');
    
    // Resize and encode to required type
    $img = Image::make($file)->fit(300)->encode('jpg');
    
    //Provide own name
    $name = time() . '.jpg';
    
    //Put file with own name
    Storage::put($name, $img);
    
    //Move file to your location 
    Storage::move($name, 'public/image/' . $name);
    

提交回复
热议问题