Upload script for CKEditor

Introduction

This is a basic set of server scripts (PHP, C# and VB.net) to implement quick file uploads in CKEditor as described in its documentation.

Author:

Alfonso Martínez de Lizarrondo

Installation

1. Configuration

The instructions will mention "upload.php", please, pick just the one that matches your server environment and use that, don't copy the rest of files

Before adding the upload.php file to your server, open it with a text editor and at the start you can see 3 steps that must be performed:

  1. Authentication: Verify that the user is allowed to use the script. If you are not careful any robot will use your script to upload files to your server. And then they might be able to execute code on your server, well, this is not longer your server, it's theirserver.
  2. Server upload path: Put here the path to the server folder where you want to store the uploads
  3. Url: Put the public URL that maps to the previous folder

2. Copying the files

Copy the upload.php to a folder in your server that it's accesible to the users that are allowed to upload files. Be careful, many malicious robots will try to look for common folder and script names like "upload", "CKEditor", etc... If the script is secured properly this shouldn't be a problem, but there are always unexpected bugs everywhere so it's better to close as many doors as possible. You can even use another name for the script itself.

3. Adding it to CKEditor

Now put the path of this script in your CKEditor configuration. If you have placed it in "/uploader/upload.php" then just state that:

config.filebrowserUploadUrl ='/uploader/upload.php'; 

Clear your cache and load CKEditor now. If you have made this last change correctly now when you open the image dialog you should see the Upload tab as shown in the first image here

Select that tab and use the "select file" and "upload to server buttons". If you have made the changes in the upload.php file correctly (and the path set in filebrowserUploadUrl is also correct) then the file will be uploaded and its url will be shown in the first tab of the Image dialog

Disclaimers

CKEditor is © CKSource.com

This script is provided "as is", I'm not responsible for any problem due to its usage or misconfiguration.