Home Tutorial CKEDITOR Upload Image In PHP

CKEDITOR Upload Image In PHP

by MH RISHAD - 26 Oct 2019

Image upload with CK-Editor. If you want to build any CMS or any other web system in which you have use CKEDITOR HTML editor. Now you want to upload a Image from using CKEDITOR using in PHP script. In this here we have make on this post, and we have step by step describe how to make custom image upload in CK-Editor from your PHP script. We know CK-Editor is a mostly  used HTML editor in any web based application, and it is very easy to use, and it is very easy to integrate in our application.

Here describe 2 step :

1 – How to Integrate CKEDITOR

2 - PHP script for upload Image.


1 - How to Integrate CKEDITOR

If you want to use CK-Editor in your PHP based web application, then need to first you have to download CK-Editor from it's official site or you can directly use CDN  for CK-Editor for it's official site also.

Link :

How to use :

CDN : <script src="//"></script>

Copy js script into footer in your webpage

 CKEDITOR.replace( ‘editor, {
  filebrowserUploadUrl: "upload.php"


Form script “editor”is id where you want show example:

<textarea id="editor1" name="content "></textarea>

You may see editor like this.

2. Now make PHP Script for upload Image:

When  you have done to integrate CK-Editor into HTML code, Now you make to PHP script for upload image from local computer to upload folder Source code you can find below.


 $file = $_FILES['upload']['tmp_name'];
 $file_name = $_FILES['upload']['name'];
 $file_name_array = explode(".", $file_name);
 $extension = end($file_name_array);
 $new_image_name = rand() . '.' . $extension;
 chmod('upload', 0766);
 $allowed_extension = array("jpg", "gif", "png");
 if(in_array($extension, $allowed_extension))
  move_uploaded_file($file, 'upload/' . $new_image_name);
  $function_number = $_GET['CKEditorFuncNum'];
  $url = 'image/' . $new_image_name;
  $message = '';
  echo "<script type='text/javascript'>$function_number, '$url', '$message');</script>";



This is fully step by step process, how to integrate CK-Editor  in your PHP application

Thank You


Leave a Comment

Required fields are marked *