CKEditor, Image Upload (filebrowserUploadUrl)

前端 未结 12 1489
误落风尘
误落风尘 2020-12-04 13:09

I\'m using CKEditor and would like to be able to allow users to upload and embed images in the Text Editor...

The following JS is what loads the CKEditor:

         


        
12条回答
  •  生来不讨喜
    2020-12-04 13:47

    If you don't want to have to buy CKFinder, like I didn't want to buy CKFinder, then I wrote a very reliable uploader for CKEditor 4. It consists of a second form, placed immediately above your textarea form, and utilizes the iframe hack, which, in spite of its name, is seamless and unobtrusive.

    After the image is successfully uploaded, it will appear in your CKEditor window, along with whatever content is already there.

    editor.php (the form page):

    
    
    
    
    Content Editor
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is changed.
    Insert image:   
    Site:  Page: 


    And here is the action page, editaction.php, which does the actual file upload:

     $v){
        ${"$k"} = $v;
    }
    //fileuploader.php
    if($_FILES){
      $target_path = "external/images/cms/";
      $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
      if(! file_exists("$target_path$filename")){
        move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path);
      }
    }
    else{
        $string = stripslashes($editor);
        $filename = "$site/$page.html";
        $handle = fopen($filename,"w");
        fwrite($handle,$string,strlen($string));
        fclose($handle);
        header("location: editor.php?r=$filename");
    }
    ?>
    

提交回复
热议问题