Laravel 9 Image Upload In Summernote Editor

Websolutionstuff | Mar-24-2022 | Categories : Laravel PHP

In this article, we will see laravel 9 image upload in summernote editor. there are many editor available in laravel to save the rich text. here we will use summernote editor. summernote editor is a simple but customizable, powerful rich text editor for the web, here you can image upload in summernote editor using laravel 9.

So, let's see image upload in summernote editor using laravel 9, how to upload image in summernote editor in laravel 9, laravel 9 summernote editor with image upload.

Here, I have ceated one controller to upload image in summernote editor.

php artisan make:controller ImageUploadController



Now, copy below code in this location app/Http/Controllers/ImageUploadControler.php


namespace App\Http\Controllers;

use Illuminate\Http\Request;

class ImageUploadController extends Controller
    public function image()
        return view('summernote');

    public function upload(Request $request)
        $this->validate($request, [
            'description' => 'required',

        $dom = new \DomDocument();
        $dom->loadHtml($description, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);    
        $images = $dom->getElementsByTagName('img');

        foreach($images as $k => $img){
            $data = $img->getAttribute('src');

            list($type, $data) = explode(';', $data);
            $data = base64_decode($data);

            $image_name= "/upload/" . time().$k.'.png';
            $path = public_path() . $image_name;

            file_put_contents($path, $data);
            $img->setAttribute('src', $image_name);

        $description = $dom->saveHTML();


Now, create blade file for view.

<!DOCTYPE html>
    <title>Laravel 9 Image Upload In Summernote Editor - Websolutionstuff</title>
    <script type="text/javascript" src=""></script> 
    <link rel="stylesheet" 
    href="" />
    <script type="text/javascript" src=""></script>
    <link href="" rel="stylesheet">
    <script src=""></script>
    <div class="row" style="margin-top: 50px;">
        <div class="col-md-8 col-md-offset-2">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <h4>Laravel 9 Image Upload In Summernote Editor - Websolutionstuff</h4>
                <div class="panel-body">
                    <form method="POST" action="{{ route('image.upload') }}">
                        {{ csrf_field() }}
                        <div class="form-group">
                            <textarea class="form-control summernote" name="description"> 
                        <button type="submit" class="btn btn-success">Submit</button>
    <script type="text/javascript">
        $(document).ready(function() {
               height: 200,


You might also like :

Recommended Post
Featured Post
Laravel 9 Multiple Database Connections
Laravel 9 Multiple Database Co...

In this tutorial, we will see laravel 9 multiple database connections. we will implement how to use laravel 9 multi...

Read More


Laravel 8 Inner Join Query Example
Laravel 8 Inner Join Query Exa...

In this tutorial we will learn about laravel 8 inner join query example. Also see how to join two tables in laravel 8. I...

Read More


How To Install Python In Windows
How To Install Python In Windo...

In this article, how to install python on windows. Python is a high-level, interpreted, general-purpose programming...

Read More


Stripe Payment Gateway Integration Example In Laravel 8
Stripe Payment Gateway Integra...

In this article, we will see a stripe payment gateway integration example in laravel 8. The stripe payment gateway...

Read More