mardi 6 février 2018

Laravel resize and upload to storage

I am trying to resize, rename and upload the image using laravel Storage, intervention on laravel5. Here is my upload code:

if( $request->file('logo_image') ){
        $logo_path = $request->file('logo_image')->store('university/'.Auth::User()->id);
                   if ( $logo_path ){
                    Storage::delete($university->logo_image);
                }
                $university->logo_image = $logo_path;
}
        $university->update();

It is storing the image on folder like: storage/app/public/university/1/fjkdhjkfdh.jpg

Now I want to rename image name like university-name.jpg and also resize and upload to sam directory. So I should have two images one is storage/app/public/university/1/university-name.jpg.jpg and other is storage/app/public/university/1/thumbnail/university-name.jpg

I play around with this for the whole day but no success.

if(Input::file())
    {

        $image = Input::file('image');
        $filename  = time() . '.' . $image->getClientOriginalExtension();

        $path = public_path('profilepics/' . $filename);


            Image::make($image->getRealPath())->resize(200, 200)->save($path);
            $user->image = $filename;
            $user->save();
       }

Please someone can help me? Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire