Drag and Drop File Upload Using Dropzone js in Laravel 9

Websolutionstuff | Mar-19-2022 | Categories : Laravel PHP jQuery

In this article, we will see drag and drop file upload using dropzone js in laravel 9. Dropzone JS is an open-source library that provides drag and drops file uploads with image previews.

Here, we will see the dropzone image upload tutorial in laravel 9. So, I will teach you laravel dropzone multiple files upload, dropzone is a javascript jquery plugin, using dropzone.js we can select one by one image with preview. After choosing an image from browse we can see the preview of the image. dropzone.js also provide filter like we can make validation for max upload, a specific image or file extension, etc.

So, let's see dropzone image upload in laravel 9, laravel 9 dropzone multiple files upload, drag and drop file upload jquery laravel 9.

Step 1 : Add Route In web.php File

In this step, we will add routes on the web.php file.

Route::get('dropzone/example', 'App\Http\Controllers\UserController@dropzoneExample');
Route::post('dropzone/store', 'App\Http\Controllers\UserController@dropzoneStore')->name('dropzone.store');



Step 2 : Create Controller

Now, create a controller and add the below code for image upload.

Note : Create a new images folder in your public folder to save image.


namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;

class UserController extends Controller

    public function dropzoneExample()
        return view('dropzone_view');

    public function dropzoneStore(Request $request)
        $image = $request->file('file');

        $imageName = time().'.'.$image->extension();
        return response()->json(['success'=>$imageName]);


Step 3 : Add Blade File For View

 In this step, create blade file for view output in this path resources\views\dropzone_view.blade.php

    <title>Drag and Drop File Upload Using Dropzone js in Laravel 9 - websolutionstuff.com</title>
    <link href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>  
    <link href="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.0.1/min/dropzone.min.css" rel="stylesheet">
     <script src="https://cdnjs.cloudflare.com/ajax/libs/dropzone/4.2.0/min/dropzone.min.js"></script>
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <h1 class="text-center">Drag and Drop File Upload Using Dropzone JS in Laravel 9 - websolutionstuff.com</h1><br>
            <form action="{{route('dropzone.store')}}" method="post" name="file" files="true" enctype="multipart/form-data" class="dropzone" id="image-upload">
                <h3 class="text-center">Upload Multiple Images</h3>
<script type="text/javascript">
        Dropzone.options.imageUpload = {
            maxFilesize: 1,
            acceptedFiles: ".jpeg,.jpg,.png,.gif"



Output :



You might also like :

Recommended Post
Featured Post
Laravel 9 CRUD Operation Example
Laravel 9 CRUD Operation Examp...

As we know Laravel 9 was officially released yesterday with many new functionalities like Symfony 6.0 components, Symfon...

Read More


How To Validate International Phone Number Using jQuery
How To Validate International...

In this article, we will see how to validate international phone numbers using jquery. Here, we will learn about mo...

Read More


How To Create Validation Rule In Laravel 10
How To Create Validation Rule...

In this article, we will see how to create a validation rule in laravel 10. Here, we will learn about the laravel 1...

Read More


How To Encrypt And Decrypt String In Laravel 8
How To Encrypt And Decrypt Str...

In this example we will see how to encrypt and decrypt string in laravel 8 using crypt helper, As we all know laravel fr...

Read More