You are here

ckeditor.upload.inc in elFinder file manager 6.2

File

editors/ckeditor/ckeditor.upload.inc
View source
<?php

function elfinder_editor_upload_ckeditor() {
  $p = elfinder_get_user_profile();
  $dest = isset($p->settings['ckeditor_upload_directory']) ? elfinder_parse_path_tokens($p->settings['ckeditor_upload_directory']) : file_directory_path();
  $tmf = $_FILES;
  foreach (array_keys($_FILES['upload']) as $key) {
    $tmpf['files'][$key]['upload'] = $_FILES['upload'][$key];
  }
  $_FILES = $tmpf;
  $file = file_save_upload('upload', array(), $dest);
  file_set_status($file, FILE_STATUS_PERMANENT);
  header('Content-Type: text/html');
  print '<script type="text/javascript">';
  if ($file) {
    print "window.parent.CKEDITOR.tools.callFunction(2, '" . file_create_url($file->filepath) . "', '');";
  }
  else {
    print "window.parent.CKEDITOR.tools.callFunction(2, '', '" . t('Error uploading file!') . "');";
  }
  print '</script>';
  exit;
}

Functions