This work's for me:
Step 1
Use Intervention Image package for manipulating images. You'll install it via composer. Run the command:
composer require intervention/image
Step 2
After installing Intervention Image, you need to add service providers and facade. Open our config/app.php file and add following lines. In the $providers array add the service providers for this package.
Intervention\Image\ImageServiceProvider::class
Step 3
Add the facade of this package to the $aliases array.
'Image' => Intervention\Image\Facades\Image::class
Step 4
And finally publish the configuration using following command:
$ php artisan vendor:publish --provider="Intervention\Image\ImageServiceProviderLaravel5"
Step 5 Controller
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use DB; use App\yourmodel; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Input; use Response; use Image; class YourController extends Controller { public function create() { return view('yourview.create'); } public function store(Request $request) { $file = Input::file('pic'); $img = Image::make($file); Response::make($img->encode('jpeg')); $var = new YourModel; $var->pic = $img; $var->save(); return redirect()->route('yourview.index') ->with('success','Success.'); }
Step 6 View
<form action="{{ route('yourview.store') }}" method="POST" enctype="multipart/form-data"> @csrf <div class="row"> <div class="col-xs-4 col-sm-4 col-md-4"> <div class="form-group"> <strong>Image:</strong> <input type="file" id="pic" name="pic" class="form-control"></input> </div> </div> <div class="col-xs-12 col-sm-12 col-md-12 text-center"> <button type="submit" class="btn btn-primary">Send</button> </div> </div> </form>