Debbie Clay

Debbie Clay


A Guide To Compress And Upload Images In Laravel 5.8

If you wanted to compress image in laravel 5 application then you are a right place. I will guide you how to compress image before upload using intervention in laravel 5.8. We can easily image minify or image compression in laravel.

Using intervention we can easily compress image of png, jpeg, jpg, gif, svg etc.

We will use intervention/image package for **compress **or resize **image **in Laravel 5.8. intervention provide a resize function that will take a three parameters. three parameters are width, height and callback function. callback function is a optional.

So here i write step by step tutorial of compress and upload image in Laravel 5.8. So just follow bellow step to create image **example **for your project.

Step 1: Install Laravel 5.8

In this step, if you haven’t Laravel 5.8 application setup then we have to get fresh **laravel 5.8 **application. So run bellow command and get clean fresh Laravel 5.8 application.

composer create-project --prefer-dist laravel/laravel blog

Step 2: Install Intervention Image

In second step we will install intervention/image for resize image. this package through we can generate thumbnail image for our project. so first fire bellow command in your cmd or terminal:

composer require intervention/image

Now we need to add provider path and alias path in config/app.php file so open that file and add bellow code.


return [
    $provides => [
    $aliases => [
        'Image' => 'Intervention\Image\Facades\Image'

Step 3: Create Routes

In this step we will add routes and controller file so first add bellow route in your routes.php file.


Route::get('resizeImage', 'ImageController@resizeImage');
Route::post('resizeImagePost', 'ImageController@resizeImagePost')->name('resizeImagePost');

Step 4: Create Controller File

Now require to create new ImageController for image uploading and resizeing image so first run bellow command :

php artisan make:controller ImageController

After this command you can find ImageController.php file in your app/Http/Controllers directory. open ImageController.php file and put bellow code in that file.


namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use Image;
class ImageController extends Controller
     * Show the form for creating a new resource.
     * @return \Illuminate\Http\Response
    public function resizeImage()
        return view('resizeImage');
     * Show the form for creating a new resource.
     * @return \Illuminate\Http\Response
    public function resizeImagePost(Request $request)
        $this->validate($request, [
            'title' => 'required',
            'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
        $image = $request->file('image');
        $input['imagename'] = time().'.'.$image->getClientOriginalExtension();
        $destinationPath = public_path('/thumbnail');
        $img = Image::make($image->getRealPath());
        $img->resize(100, 100, function ($constraint) {
        $destinationPath = public_path('/images');
        $image->move($destinationPath, $input['imagename']);
        return back()
            ->with('success','Image Upload successful')

Step 5: Blade and Create Upload directory

Ok, in this last step we will create resizeImage.blade.php file for photo upload form and manage error message and also success message. So first create resizeImage.blade.php file and put bellow code:


<div class="container">
<h1>Resize Image Uploading Demo</h1>
@if (count($errors) > 0)
    <div class="alert alert-danger">
        <strong>Whoops!</strong> There were some problems with your input.<br><br>
            @foreach ($errors->all() as $error)
                <li>{{ $error }}</li>
@if ($message = Session::get('success'))
<div class="alert alert-success alert-block">
    <button type="button" class="close" data-dismiss="alert">×</button>    
    <strong>{{ $message }}</strong>
<div class="row">
    <div class="col-md-4">
        <strong>Original Image:</strong>
        <img src="/images/{{ Session::get('imageName') }}" />
    <div class="col-md-4">
        <strong>Thumbnail Image:</strong>
        <img src="/thumbnail/{{ Session::get('imageName') }}" />
{!! Form::open(array('route' => 'resizeImagePost','enctype' => 'multipart/form-data')) !!}
    <div class="row">
        <div class="col-md-4">
            {!! Form::text('title', null,array('class' => 'form-control','placeholder'=>'Add Title')) !!}
        <div class="col-md-12">
            {!! Form::file('image', array('class' => 'image')) !!}
        <div class="col-md-12">
            <button type="submit" class="btn btn-success">Upload Image</button>
{!! Form::close() !!}

Ok, at last create two directory in your public folder (1)images and (2)thumbnail and please give permission to that folder and check…

I hope it can help you…

#laravel #php #web-development #image

What is GEEK

Buddha Community

A Guide To Compress And Upload Images In Laravel 5.8

Laravel 8 Image Upload Example

In this post I will explain laravel 8 image upload example, image or file upload is most common task in web developing so here, i will show you how to upload image in laravel 8.

Here we will see laravel 8 upload image to public folder, So here we will create two routes, one for get method and second for post method. and also we are creating basic form with file input. So you have to simple select image and then it will upload in “images” directory of public folder.

Laravel 8 Image Upload Example

#laravel 8 image upload example #laravel8 #image upload #how to upload image in laravel 8 #image upload in laravel 8 #laravel 8 image upload with preview

I am Developer


Laravel 7/6 Image Upload Example Tutorial

Laravel image upload example tutorial. Here, i will show you how to upload image in laravel 7/6 with preview and validation.

Before store image into db and folder, you can validate uploaded image by using laravel validation rules. as well as you can show preview of uploaded image in laravel.

Image Upload In Laravel 7/6 with Validation

Image upload in laravel 7/6 with preview and validation. And storage image into folder and MySQL database by using the below steps:

Install Laravel Fresh App
Setup Database Details
Generate Image Migration & Model
Create Image Upload Route
Create Image Controller
Create Image Upload and Preview Blade View
Start Development Server

#laravel 7 image upload example #laravel upload image to database #how to insert image into database in laravel #laravel upload image to storage #laravel image upload tutorial #image upload in laravel 7/6

I am Developer


Crop and Resize Image Before Upload In Laravel Using with jQuery Copper JS

Crop and resize image size before upload in laravel using jquery copper js. In this post, i will show you how to crop and resize image size in laravel using jQuery copper js in laravel.

This laravel crop image before upload using cropper js looks like:

laravel crop image before upload

Laravel Crop Image Before Uploading using Cropper js Tutorial

Laravel crop image before upload tutorial, follow the following steps and learn how to use cropper js to crop image before uploading in laravel app:

  • Step 1: Install New Laravel App
  • Step 2: Add Database Details
  • Step 3: Create Migration & Model
  • Step 4: Add Route
  • Step 5: Create Controller By Artisan
  • Step 6: Create Blade View
  • Step 7: Make Upload Directory
  • Step 8: Start Development Server


Live Demo Laravel Crop image Before Upload.

#laravel crop image before upload, #laravel crop and resize image using cropper.js #ajax image upload and crop with jquery and laravel #crop and upload image ajax jquery laravel #crop image while uploading with jquery laravel #image crop and upload using jquery with laravel ajax

I am Developer


Ajax Multiple Image Upload with Progress bar with jQuery in Laravel

In this post, i will show you, how you can upload multiple file with progress bar in laravel using jQuery ajax.

So follow below given steps to create ajax multiple image upload with progress bar with jquery and laravel php.

Multiple File Upload with Progress bar Using jQuery and Laravel PHP

Now follow the below given simple and easy step to upload multiple file with progress bar in laravel using jQuery ajax:

  • Step 1: Download Laravel App
  • Step 2: Add Database Details
  • Step 3: Create Migration & Model
  • Step 4: Add Routes For Multiple File Upload
  • Step 5: Create Controller by Artisan
  • Step 6: Create Blade View
  • Step 7: Run Development Server

#multiple file upload with progress bar using jquery and laravel #laravel multiple file upload ajax with progress bar #how to upload multiple images with progress bar in laravel #laravel 7 multiple image upload example #image upload with progress bar laravel #laravel multiple image upload ajax

I am Developer


Laravel 7 Multiple Image Upload with Preview

Here, i will show you how to upload multiple image with preview using ajax in laravel.

Laravel 7 Ajax Multiple Image Upload with Preview

Just follow the below steps and upload multiple images using ajax with showing preview in laravel applications:

  • Install Laravel Fresh Setup
  • Setup Database Credentials
  • Create Route
  • Generate Controller By Command
  • Create the blade view
  • Start Development Server

#laravel multiple image upload with preview #laravel multiple image validation #display multiple images in laravel #laravel multiple file upload #multiple image upload in laravel 6 #ajax image upload and preview with laravel