upload image with ckeditor in laravel 8

  ckeditor, javascript, laravel-8, php

i´m traying to upload img with ckeditor in my laravel 8. i can upload my img to my folder ok, but when i tray save data return alert that i need set URL img in input URL. It´s my first time with ckeditor and i don´t know very well how i can to do this.

My function to upload img to my server it´s:

public function ckEditorUploadFile($data)
        $name = $data["name"];

        $dom = new DomDocument();
        $dom->encoding = 'utf-8';
        @$dom->loadHtml(utf8_decode($data['content']), LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
        $images = $dom->getElementsByTagName('img');
        foreach ($images as $k => $img) {
            $image = $img->getAttribute('src');
            if (strstr($image, 'uploads') == false) {
                list($type, $image) = explode(';', $image);
                $ext = explode("/", $type);
                list(, $image) = explode(',', $image);
                $image = base64_decode($image);
                $image_name = Str::slug($name). '-' . $k . '-' . time()  . '.' . end($ext);
                Storage::disk('public')->put('uploads/'.$image_name, $image);
                $img->setAttribute('src', asset('storage/uploads/'.$image_name));

        $data["content"] = $dom->saveHTML();
        return $data;

this function upload ok to my img to folder storage/app/uploads but i need set URL img in input for i can to continue with my implementation. now i can´t show my img in my editor.

Thanks for read and help me

Source: Ask Javascript Questions