---
title: "How to Upload Images in Summernote Editor Using Laravel 12?"
url: "https://magecomp.com/blog/upload-images-in-summernote-editor-laravel-12/"
date: "2026-05-20T12:59:34+00:00"
modified: "2026-05-20T12:59:38+00:00"
author:
  name: "Bharat Desai"
  url: "https://magecomp.com"
categories:
  - "Laravel"
word_count: 1059
reading_time: "6 min read"
summary: "In the tutorial provided here, you will see how to add Summernote (a WYSIWYG editor) along with image upload capabilities in Laravel 12."
description: "Learn how to upload images in Summernote Editor using Laravel 12. Step-by-step guide with example code."
keywords: "Laravel"
language: "en"
schema_type: "Article"
related_posts:
  - title: "Leveraging Laravel Helpers: Simplifying Development Tasks"
    url: "https://magecomp.com/blog/laravel-helpers/"
  - title: "A Comprehensive Guide to Laravel Twilio Integration"
    url: "https://magecomp.com/blog/laravel-twilio-integration/"
  - title: "Laravel: How to Add Form Validation in the Request Controller"
    url: "https://magecomp.com/blog/laravel-add-form-validation-in-the-request-controller/"
---

# How to Upload Images in Summernote Editor Using Laravel 12?

_Published: May 20, 2026_  
_Author: Bharat Desai_  

![How to Upload Images in Summernote Editor Using Laravel 12](https://magecomp.com/blog/wp-content/uploads/2026/05/How-to-Upload-Images-in-Summernote-Editor-Using-Laravel-12-1024x512.webp)

In the tutorial provided here, you will see how to add Summernote (a WYSIWYG editor) along with image upload capabilities in Laravel 12.

The goal is to have users create rich text posts as well as upload images directly through Summernote. We will go through the entire process of creating an actual blog module. This includes the migration for creating a posts database, posts table, posts model, posts controller, routes required for managing the posts, and displaying the uploaded images in the Summernote. This is step-by-step, using very simple examples so even beginners will be able to implement, but flexible enough for advanced users as well.

[![Laravel Development Services](https://magecomp.com/blog/wp-content/uploads/2024/12/Laravel-Development-Services-4-1024x284.webp)](https://magecomp.com/services/laravel-development-services/)

## Steps to Upload Images in Summernote Editor Using Laravel 12:
### Step 1: Install Laravel 12
If you don’t have your own Laravel app created, you can run the command below:

```
composer create-project laravel/laravel example-app
```

### Step 2: Create the Posts Table and Model
In this step, we need to create a new migration to add a “posts” table.

```
php artisan make:migration create_posts_table
```

**database/migrations/2024_02_17_133331_create_posts_table.php**

```
<?php

use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;

return new class extends Migration
{
   /**
   * Run the migrations.
   *
   * @return void
   */
   public function up(): void
   {
       Schema::create('posts', function (Blueprint $table) {
            $table->id();
            $table->string('title');
            $table->text('body');
            $table->timestamps();
        });
   }

  **
  * Reverse the migrations.
  *
  * @return void
  */
  public function down(): void
  {
     Schema::dropIfExists('posts');
  }
};
```

Now, let’s run the migration command:

```
php artisan migrate
```

Now we need to create the Post Model and add the following code:

**app/Models/Post.php**

```
<?php
namespace AppModels;
use IlluminateDatabaseEloquentFactoriesHasFactory;
use IlluminateDatabaseEloquentModel;
use IlluminateDatabaseEloquentCastsAttribute;

class Post extends Model
{
   use HasFactory;

   /**
   * Write code on Method
   *
   * @return response()
   */

   protected $fillable = ['title', 'body'];

   /**
   * Get the user's first name.
   */

   protected function body(): Attribute
   {
         return Attribute::make(
            set: fn (string $value) => $this->makeBodyContent($value),
            );
        }

   	/**
     	* Write code on Method
     	*
     	* @return response()
     	*/

        public function makeBodyContent($content)
    	{
        	$dom = new DomDocument();
       		$dom->loadHtml($content, LIBXML_HTML_NOIMPLIED | 			                            LIBXML_HTML_NODEFDTD);
        	$imageFile = $dom->getElementsByTagName('img');

       		foreach($imageFile as $item => $image){
            		$data = $image->getAttribute('src');
            		list($type, $data) = explode(';', $data);
           		list(, $data) = explode(',', $data);
            		$imgeData = base64_decode($data);
            		$image_name= "/uploads/" . time().$item.'.png';
            		$path = public_path() . $image_name;
            		file_put_contents($path, $imgeData);
            		$image->removeAttribute('src');
            		$image->setAttribute('src', $image_name);
        	}

        	return $dom->saveHTML();
    	}
}
```

### Step 3: Create the Routes
In this step, we need to create some routes for listing posts and creating posts.

**routes/web.php**

```
<?php

use IlluminateSupportFacadesRoute;
use AppHttpControllersPostController;
Route::get('posts/create',[PostController::class,'create']);
Route::post('posts/store',[PostController::class,'store'])->name('posts.store');
```

### Step 4: Create Controller
In this step, we will create a new PostController where we will be writing the image upload code to process and upload the images to our public/uploads directory. All of your code will be added to the PostController.

**app/Http/Controllers/PostController.php**

```
<?php
namespace AppHttpControllers
use IlluminateHttpRequest;
use AppModelsPost;
use IlluminateViewView;
use IlluminateHttpRedirectResponse;

class PostController extends Controller
{
   	/**
     	* Write code on Method
     	*
     	* @return response()
     	*/

    	public function create(): View
    	{
       		return view('postsCreate');
    	}

   	/**
     	* Write code on Method
     	*
    	* @return response()
     	*/

   	public function store(Request $request): RedirectResponse
    	{
        	$this->validate($request, [
            		'title' => 'required',
            		'body' => 'required'
        	]);

       		$post = Post::create([
            		'title' => $request->title,
            		'body' => $request->body
        	]);

       		return back()
                ->with('success','Post created successfully.');
        }
}
```

### Step 5: Create Blade File
Here, we need to create a Blade file for the create form. So let’s create one file.

**resources/views/postsCreate.blade.php**

```

<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
        <meta charset="utf-8">
    	<meta name="viewport" content="width=device-width, initial-scale=1">
    	<title>Laravel 12 Summernote Editor Image Upload Example</title>
    	      	    </head>
    <body>
            	           	        <h3 class="card-header p-3">Laravel 12 Summernote Editor Image Upload </h3>

                    <form method="post" action="{{ route('posts.store') }}" 		enctype="multipart/form-data">
                        @csrf
                	                    	    <label>Title</label>
                    	    <input type="text" name="title" class="form-control" />
                	                	                            <label>Description</label>
                            <textarea id="summernote" name="body"></textarea>
                	                      	                	    <button type="submit" class="btn btn-success btn-block">Publish</button>
                	                    </form>
                                            <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">         </script>
        <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0/dist/js/bootstrap.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.20/summernote-bs5.min.js"></script>

        <script type="text/javascript">
            $(document).ready(function () {
                $('#summernote').summernote({
                    height: 300,
                 });
            });
        </script>

    </body>
</html>
```

### Run Laravel App:
All steps have been completed, and your next step is to type the command below and hit enter to run your Laravel app:

```
php artisan serve
```

After this, open the web browser and type the URL below into the web browser’s address bar and you should see the output generated from your application:

<http://localhost:8000/posts/create>

## Conclusion
In this tutorial, we’ve created a rich text editor with image upload capability within Laravel 12. We have set up the database, created models, and established routes and controller logic. We’ve integrated Summernote as the front-end display for images you wish to upload. Once this implementation has been completed, your users will have an easier time uploading and managing images as they create blog posts in the Summernote rich text editor. This method is a good way to improve how you manage content in a Laravel application, and also provides your users with a much nicer experience as they edit content.

[![Hire laravel Developer](https://magecomp.com/blog/wp-content/uploads/2024/12/Hire-Laravel-Expert-Now-3-1024x284.webp)](https://magecomp.com/services/hire-laravel-developer/)

## FAQ
**1. What is Summernote Editor in Laravel?**

Summernote is an open-source WYSIWYG text editor you can use anywhere in your Laravel Application to create rich text content and upload image / file attachments.

**2. How to Upload Images in Summernote Using Laravel 12?**

You can upload images into the Summernote editor by using Summernote’s onImageUpload() method, which will make an AJAX call to your Laravel controller.

</body></html>


---

_View the original post at: [https://magecomp.com/blog/upload-images-in-summernote-editor-laravel-12/](https://magecomp.com/blog/upload-images-in-summernote-editor-laravel-12/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-05-24 17:26:50 UTC_  
