Laravel 5 – Multiple Images Uploading with drag and drop using dropzone.js example

Laravel 5 – Multiple Images Uploading with drag and drop using dropzone.js example

In this post we will give you information about Laravel 5 – Multiple Images Uploading with drag and drop using dropzone.js example. Hear we will give you detail about Laravel 5 – Multiple Images Uploading with drag and drop using dropzone.js exampleAnd how to use it also give you demo for it if it is necessary.

In this PHP Laravel Tutorial, I will tell you how to upload multiple images with preview using dropzone.js with example.

There are many plugins available to upload multiple images with preview. Dropzone provides the easiest way to upload multiple files with best user interface.

Dropzone is an open source and light weight JavaScript library that provides the drag and drop features to upload images with preview images.

Dropzone does not handle the server side script so you will have to write your own code to save file in a specific path.

There are filter options with dropzone such as you can set validation for max upload or apply restriction to upload only image file or have any other file extension.

For this example, you will need the dropzone library :

  1. dropzone.css
  2. dropzone.js

Step 1: Routes

In this first step, We will add two following routes :


  1. Route::get('dropzoneFile','HomeController@dropzoneFile');
  2. Route::post('dropzoneUploadFile',array('as'=>'dropzone.uploadfile','uses'=>'HomeController@dropzoneUploadFile'));
Route::get('dropzoneFile','HomeController@dropzoneFile') ;
Route::post('dropzoneUploadFile',array('as'=>'dropzone.uploadfile','uses'=>'HomeController@dropzoneUploadFile')) ;

First route is used to render view file and second routes is used to save file uploaded with dropzone plugin.

Step 2: HomeController with two Method

In this step, We will create HomeController file in following path app/Http/Controllers/ and define two method in following way :


  1. <?php
  2. namespace AppHttpControllers;
  3. use AppHttpRequests;
  4. use IlluminateHttpRequest;
  5. class HomeController extends Controller
  6. {
  7. public functiondropzoneFile(){
  8. returnview('dropzone_file_upload');
  9. }
  10. public functiondropzoneUploadFile(Request $request){
  11. $imageName=time().'.'.$request->file->getClientOriginalExtension();
  12. $request->file->move(public_path('images'),$imageName);
  13. returnresponse()->json(['success'=>$imageName]);
  14. }
  15. }

namespace AppHttpControllers;

use AppHttpRequests;
use IlluminateHttpRequest;

class HomeController extends Controller

    public function dropzoneFile(){
        return view('dropzone_file_upload');

    public function dropzoneUploadFile(Request $request){
        $imageName = time().'.'.$request->file->getClientOriginalExtension();
        $request->file->move(public_path('images'), $imageName);
        return response()->json(['success'=>$imageName]);


Now create a folder “images” in public directory to store all files.

Step 3: Add Blade File

In this last step, We will create a view file “dropzone_file_upload.blade.php” in following path resources/views/.


  1. <!DOCTYPEhtml>
  2. <htmllang="en">
  3. <head>
  4. <metacharset="utf-8">
  5. <metahttp-equiv="X-UA-Compatible"content="IE=edge">
  6. <metaname="viewport"content="width=device-width, initial-scale=1">
  7. <title>Laravel: upload multiple file using drag and drop feature</title>
  8. <linkhref="//css/dropzone.css"rel="stylesheet">
  9. <scriptsrc="//js/dropzone.js"></script>
  10. </head>
  11. <body>
  12. <h3>Laravel 5.4 : Upload multiple file using dropzone</h3>
  13. {!! Form::open([ 'route' => [ 'dropzone.uploadfile' ], 'files' => true, 'class' => 'dropzone','id'=>"image-upload"]) !!}
  14. {!! Form::close() !!}
  15. </body>
  16. </html>
<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Laravel: upload multiple file using drag and drop feature</title>
    <link href="//css/dropzone.css" rel="stylesheet">
    <script src="//js/dropzone.js"></script>

<h3>Laravel 5.4 : Upload multiple file using dropzone</h3>
{!! Form::open([ 'route' => [ 'dropzone.uploadfile' ], 'files' => true, 'class' => 'dropzone','id'=>"image-upload"]) !!}

{!! Form::close() !!}


You can set the validation option with dropzone in following way :

  1. <script type="text/javascript">
  2. Dropzone.options.imageUpload ={
  3. maxFilesize :1,
  4. acceptedFiles:".jpeg,.jpg,.png,.gif"
  5. };
  6. </script>
<script type="text/javascript">
        Dropzone.options.imageUpload = {
            maxFilesize  : 1,
            acceptedFiles: ".jpeg,.jpg,.png,.gif"

Show Demo

Hope this code and post will helped you for implement Laravel 5 – Multiple Images Uploading with drag and drop using dropzone.js example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

2  +  8  =  

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US