Thinkphp integrates the ckeditor method and uses the ckfinder function to upload images.

Source: Internet
Author: User
Recently I used thinkphp to create a project and used a rich text editor. a text editor does not have the same image upload function. I found many related methods on my website, but I didn't find a proper one, after constantly trying to sort out the website methods

Recently I used thinkphp to create a project and used a rich text editor. a text editor does not have the same image upload function. I found many related methods on my website, but I didn't find a proper one, after constantly trying to sort out the website methods and implement the functions you want, I will show the code to you.

1. download the ckeditor editor.

This is the basic structure of the ckeditor folder.

2. decompress it to the PUBLIC folder.

Reference ckeditor. js in the file

3. create a text field

Write the following code in the text field:

  1. CKEDITOR. replace ('myeditor ',
  2. {
  3. FilebrowserBrowseUrl: '_ PUBLIC _/ckfinder/ckfinder.html ',
  4. FilebrowserImageBrowseUrl: '_ PUBLIC _/ckfinder/ckfinder.html? Type = Images ',
  5. FilebrowserFlashBrowseUrl: '_ PUBLIC _/ckfinder/ckfinder.html? Type = Flash ',
  6. FilebrowserUploadUrl: '_ PUBLIC _/ckfinder/core/connector/php/connector. php? Command = QuickUpload & type = Files ',
  7. FilebrowserImageUploadUrl: '_ PUBLIC _/ckfinder/core/connector/php/connector. php? Command = QuickUpload & type = Images ',
  8. FilebrowserFlashUploadUrl: '_ PUBLIC _/ckfinder/core/connector/php/connector. php? Command = QuickUpload & type = Flash'
  9. });

MyEditor is used in the background to receive text field values.

4. at this time, the editor does not have the image upload function. next we will configure the image upload function of the text editor.

Reference ckfinder. js in the file header. after the reference is complete, we only need one step. next we will configure ckfinder/config. php.

Find "$ baseUrl" as the path for uploading images. This path is relative to the root directory.

  1. $ BaseUrl = '/ziji/public/upload /';
  2. Find CheckAuthentication and change false to true // enable the image upload function.
  3. Function CheckAuthentication ()
  4. {
  5. Return false;
  6. }

Now the text editor has the upload function.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.