Contribute to this guideReport an issue

File Upload through Dialogs and Drag&Drop Documentation

By default CKEditor 4 does not include a file manager, but it can be easily integrated with an external tool thanks to the File Browser plugin that is available in all official CKEditor 4 distributions.

Once properly set up through the config.filebrowserBrowseUrl and config.filebrowserUploadUrl configuration settings, all file manager features will automatically become available. This includes the Upload tab in the Link or Image Properties dialog windows as well as the Browse Server button.

Note: The examples on this page integrate CKEditor 4 with CKFinder, but you are free to implement your own solution thanks to the editor File Browser API or choose another existing product. Additionally, file manager integration can be customized thanks to numerous editor configuration features that make it possible to, for example, setup the integration for selected dialog windows or customize the file browser window size.

Uploading Dropped and Pasted Images

The optional Upload Image plugin enables support for uploading images that were dropped or pasted into the editor.

Drag and drop file upload is not supported in Internet Explorer 9 and below. Support for pasting images and its fragments varies depending on the browser, operating system and application from which the image or its fragment was copied. This is a new feature, so it is likely to change in the future.

The sample below uses the Upload Image plugin together with enhanced images. Additional widget styles are defined to control image size and alignment.

Try pasting or dropping images into the editor below (you can drop multiple files at a time). You can also try to paste fragments of images (e.g. copied from an image editing application).

Related Features

Get Sample Source Code

  • File Manager Integration
    <!doctype html>
    <html lang="en">
    
    <head>
      <meta charset="utf-8">
      <meta name="robots" content="noindex, nofollow">
      <title>File Manager Integration</title>
      <script src="https://cdn.ckeditor.com/4.24.0-lts/standard-all/ckeditor.js"></script>
    </head>
    
    <body>
      <textarea cols="10" id="editor1" name="editor1" rows="10">&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href=&quot;https://ckeditor.com/&quot;&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea>
      <script>
        CKEDITOR.replace('editor1', {
          height: 300,
    
          // Configure your file manager integration. This example uses CKFinder 3 for PHP.
          filebrowserBrowseUrl: '/apps/ckfinder/3.4.5/ckfinder.html',
          filebrowserImageBrowseUrl: '/apps/ckfinder/3.4.5/ckfinder.html?type=Images',
          filebrowserUploadUrl: '/apps/ckfinder/3.4.5/core/connector/php/connector.php?command=QuickUpload&type=Files',
          filebrowserImageUploadUrl: '/apps/ckfinder/3.4.5/core/connector/php/connector.php?command=QuickUpload&type=Images',
          removeButtons: 'PasteFromWord'
        });
      </script>
    </body>
    
    </html>
  • Uploading Dropped and Pasted Images
    <!doctype html>
    <html lang="en">
    
    <head>
      <meta charset="utf-8">
      <meta name="robots" content="noindex, nofollow">
      <title>Uploading Dropped and Pasted Images</title>
      <script src="https://cdn.ckeditor.com/4.24.0-lts/standard-all/ckeditor.js"></script>
    </head>
    
    <body>
      <textarea cols="10" id="editor2" name="editor2" rows="10">&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href=&quot;https://ckeditor.com/&quot;&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea>
      <script>
        CKEDITOR.replace('editor2', {
          extraPlugins: 'uploadimage,image2',
          height: 300,
    
          // Upload images to a CKFinder connector (note that the response type is set to JSON).
          uploadUrl: '/apps/ckfinder/3.4.5/core/connector/php/connector.php?command=QuickUpload&type=Files&responseType=json',
    
          // Configure your file manager integration. This example uses CKFinder 3 for PHP.
          filebrowserBrowseUrl: '/apps/ckfinder/3.4.5/ckfinder.html',
          filebrowserImageBrowseUrl: '/apps/ckfinder/3.4.5/ckfinder.html?type=Images',
          filebrowserUploadUrl: '/apps/ckfinder/3.4.5/core/connector/php/connector.php?command=QuickUpload&type=Files',
          filebrowserImageUploadUrl: '/apps/ckfinder/3.4.5/core/connector/php/connector.php?command=QuickUpload&type=Images',
    
          // The following options are not necessary and are used here for presentation purposes only.
          // They configure the Styles drop-down list and widgets to use classes.
    
          stylesSet: [{
              name: 'Narrow image',
              type: 'widget',
              widget: 'image',
              attributes: {
                'class': 'image-narrow'
              }
            },
            {
              name: 'Wide image',
              type: 'widget',
              widget: 'image',
              attributes: {
                'class': 'image-wide'
              }
            }
          ],
    
          // Load the default contents.css file plus customizations for this sample.
          contentsCss: [
            'http://cdn.ckeditor.com/4.24.0-lts/full-all/contents.css',
            'https://ckeditor.com/docs/ckeditor4/4.24.0-lts/examples/assets/css/widgetstyles.css'
          ],
    
          // Configure the Enhanced Image plugin to use classes instead of styles and to disable the
          // resizer (because image size is controlled by widget styles or the image takes maximum
          // 100% of the editor width).
          image2_alignClasses: ['image-align-left', 'image-align-center', 'image-align-right'],
          image2_disableResizer: true,
          removeButtons: 'PasteFromWord'
        });
      </script>
    </body>
    
    </html>