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:
- CKEDITOR. replace ('myeditor ',
- {
- FilebrowserBrowseUrl: '_ PUBLIC _/ckfinder/ckfinder.html ',
- FilebrowserImageBrowseUrl: '_ PUBLIC _/ckfinder/ckfinder.html? Type = Images ',
- FilebrowserFlashBrowseUrl: '_ PUBLIC _/ckfinder/ckfinder.html? Type = Flash ',
- FilebrowserUploadUrl: '_ PUBLIC _/ckfinder/core/connector/php/connector. php? Command = QuickUpload & type = Files ',
- FilebrowserImageUploadUrl: '_ PUBLIC _/ckfinder/core/connector/php/connector. php? Command = QuickUpload & type = Images ',
- FilebrowserFlashUploadUrl: '_ PUBLIC _/ckfinder/core/connector/php/connector. php? Command = QuickUpload & type = Flash'
- });
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.
- $ BaseUrl = '/ziji/public/upload /';
- Find CheckAuthentication and change false to true // enable the image upload function.
- Function CheckAuthentication ()
- {
- Return false;
- }
Now the text editor has the upload function.