mehrdad70's avatar

image upload with ckeditor in laravel

hello, iwant to upload image with ckeditor , but i get Status Code: 404 Not Found


Request URL: http://127.0.0.1:8000/ckeditor/upload/image/mh4vF3pbYIFimaNqFSMH9X8w6qNwC3W0M7lVLQkX?CKEditor=basicTextarea&CKEditorFuncNum=3&langCode=fa
Request Method: POST
Status Code: 404 Not Found
Remote Address: 127.0.0.1:8000
Referrer Policy: strict-origin-when-cross-origin
Cache-Control: no-cache, private
Connection: close
Content-type: text/html; charset=UTF-8
Date: Sun, 06 Dec 2020 15:11:03 GMT
date: Sun, 06 Dec 2020 15:11:03 GMT
Host: 127.0.0.1:8000
X-Powered-By: PHP/7.4.7
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate, br
Accept-Language: fa-IR,fa;q=0.9,en-US;q=0.8,en;q=0.7,he;q=0.6,pt;q=0.5
Cache-Control: max-age=0
Connection: keep-alive
Content-Length: 113670
<script>
    CKEDITOR.replace( 'body' , {
        filebrowserUploadUrl: "/ckeditor/upload/image/",
        filebrowserUploadMethod: 'form',
    });
 </script>
    Route::post('/ckeditor/upload/image' , 'CkEditorUploadController@ckUpload')->name('ckeditor.upload');
class CkEditorUploadController extends Controller
{
    public function ckUpload(Request $request)
    {
        $imagePath = $request->file('upload');
        $imageName = $imagePath->getClientOriginalName();
        $dir = '/upload/articles';
        $path = $imagePath->storeAs($dir, $imageName, 'public');
        $msg = 'Image uploaded successfully';

        return  "<script>window.parent.CKEDITOR.tools.callFunction(1, '$path', '$msg')</script>";
    }
}

                                                <textarea class="form-control" name="body" id="basicTextarea" rows="3" placeholder="توضیحات مقاله  "> {!!old('body')!!}</textarea>

0 likes
0 replies

Please or to participate in this conversation.