Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kerelka's avatar

Image Upload on editor WYSIWYG

Hello brothers, recently i have project that need editor wysiwyg.

i learn that you can insert images on editor and save it as base64. but, when i look again. its a big NO NO related to security concern and how big the body would be.

i know you can upload and use it on editor as alternative. but i want to know how and what flow would be the best for this case?

thank you

i use Tiptap editor and laravel 12 vue inertia

0 likes
2 replies
LaryAI's avatar
Level 58

Certainly! You are correct that saving images as base64 within your WYSIWYG editor content is not recommended due to security, performance, and storage concerns. The best practice is to upload the image to your server (or a cloud storage service), then insert the image URL into the editor content.

Here’s a typical flow for handling image uploads with a WYSIWYG editor like Tiptap:

1. User selects an image in the editor.
2. The image is uploaded to your server via AJAX (e.g., using Axios or Fetch).
3. The server stores the image and returns the public URL.
4. The editor inserts the image using the returned URL.

Example Implementation

Frontend (Tiptap + Axios)

Backend (Laravel Example)

public function store(Request $request)
{
    $request->validate([
        'image' => 'required|image|max:2048', // 2MB Max
    ]);

    $path = $request->file('image')->store('images', 'public');

    return response()->json([
        'url' => asset('storage/' . $path),
    ]);
}

HTML Example

<input type="file" id="image-input" accept="image/*" />

Summary

  • Never store images as base64 in your database.
  • Always upload images to your server or a storage service.
  • Store only the image URL in your editor content.
  • Use AJAX to handle uploads and update the editor with the returned URL.

This approach keeps your content lightweight, secure, and scalable.

Let me know if you need a more detailed example or help with a specific stack!

kerelka's avatar

@LaryAI yes this is what i already done, but what i need is when case like delete from editor, or upload and not save the entire body. if im not handle the file well, the storage will blow up 😅

Please or to participate in this conversation.