ThinkPHP整合百度Ueditor图文教程_php实例
ThinkPHP整合百度Ueditor,基于黄永成老师的视频说明的
申明:最好大家都能写绝对路径的都写好绝对路径比如:window.UEDITOR_HOME_URL
他在教程里面已经说了的,我就不再次说了啊,就一笔带过,好了不废话!
在调用编辑器的时候首先先初始化一些值:
<script type="text/javascript" charset="utf-8"> window.UEDITOR_HOME_URL = "/Public/ueditor/"; //UEDITOR_HOME_URL、config、all这三个顺序不能改变 window.onload=function(){ window.UEDITOR_CONFIG.initialFrameHeight=300;//编辑器的高度 window.UEDITOR_CONFIG.imageUrl="{:U('admin/Category/checkPic')}"; //图片上传提交地址 window.UEDITOR_CONFIG.imagePath=' /Uploads/thumb/';//编辑器调用图片的地址 UE.getEditor('contents');//里面的contents是我的textarea的id值 } </script>
然后再引入2个js文件,分别是:1、ueditor.all.min.js 2、ueditor.config.js
在这里申明一下 我以上说的调用方式,顺序绝对不能乱,乱了就会出问题了,所以你就按照我的按部就班的做吧!
因为我重写了编辑器的图片提交地址,所以我还得在控制器里面写一个对图片处理的方法。
代码如下:
//改变Ueditor 默认图片上传路径 public function checkPic(){ import('ORG.Net.UploadFile'); $upload = new UploadFile();// 实例化上传类 $upload->allowExts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型 $upload->autoSub =true ; $upload->subType ='date' ; $upload->dateFormat ='ym' ; $upload->savePath = './Uploads/thumb/';// 设置附件上传目录 if($upload->upload()){ $info = $upload->getUploadFileInfo(); echo json_encode(array( 'url'=>$info[0]['savename'], 'title'=>htmlspecialchars($_POST['pictitle'], ENT_QUOTES), 'original'=>$info[0]['name'], 'state'=>'SUCCESS' )); }else{ echo json_encode(array( 'state'=>$upload->getErrorMsg() )); } }
我首先给大家看看代码先,在继续说明,
1、引入tp官方的文件上传处理类,然后初始化一些配置,这些都不介绍了啊!
2、判断他是否上传成功了,如果上传成功了,就先获取他的上传成功的信息,然后把数组转成json,用phpjson_encode。如果上传失败就把上传失败的信息直接返回!
以上都是在黄永成老师教程里面已经说明了的!就不详细说明了,不懂的就去看视频!
在整合好了上传后,发现上传的图片路径被转义了,一直显示不出来如图:
我就在显示出数据的哪里用反转义函数,进行操作了一下{$article.content|stripslashes}这样就是把转义的字符串进行反转义,这样数据就能正常显示了
如图:
然后在前台模版显示数据的时候不仅要反转义还要去掉html实体化,{$article.content|htmlspecialchars_decode|stripslashes}这样就能正常显示了!
还有哟个问题,百度编辑器当里面的内容增长时,他的高度也是增长的,如图:
解决方案就是在Ueditor的配置文件ueditor.config.js,里面的第428行打开注释,改成true,还有430行注释打开把他改成你初始化的的高度对应就好了。如图:
这样编辑器就不会撑高了!如图:
完结!!! 说的不好的大神勿喷~~这个只是分享交流,如果说错了 指出来就行了 谢谢~~~
补充说明:关于Ueditor在ie7下面调用不出来的bug问题解决办法,这个是前天逛官网的时候,发现一个人的这个问题的,因为我只有人见人爱的ie6,也都没有去测试,所以还是别人提醒,现在更正一下ie7的bug解决方案~感谢这位大湿啊~
如图:

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

On May 15, Baidu Apollo held Apollo Day 2024 in Wuhan Baidu Luobo Automobile Robot Zhixing Valley, comprehensively demonstrating Baidu's major progress in autonomous driving over the past ten years, bringing technological leaps based on large models and a new definition of passenger safety. With the world's largest autonomous vehicle operation network, Baidu has made autonomous driving safer than human driving. Thanks to this, safer, more comfortable, green and low-carbon travel methods are turning from ideal to reality. Wang Yunpeng, vice president of Baidu Group and president of the Intelligent Driving Business Group, said on the spot: "Our original intention to build autonomous vehicles is to satisfy people's growing yearning for better travel. People's satisfaction is our driving force. Because safety, So beautiful, we are happy to see

According to news from this site on May 7, on May 6, Robin Li, founder, chairman and CEO of Baidu, led a team to visit China National Petroleum Corporation (hereinafter referred to as "PetroChina") in Beijing and met with directors of China National Petroleum Corporation Chairman and Party Secretary Dai Houliang held talks. The two parties had in-depth exchanges on strengthening cooperation and promoting the deep integration of the energy industry with digital intelligence. PetroChina will accelerate the construction of a digital China Petroleum Corporation, strengthen cooperation with Baidu Group, promote the in-depth integration of the energy industry with digital intelligence, and make greater contributions to ensuring national energy security. Robin Li said that the "intelligent emergence" and core capabilities of understanding, generation, logic, and memory displayed by large models have opened up a broader space for imagination for the combination of cutting-edge technology and oil and gas business. Always

DeepSeek is a powerful intelligent search and analysis tool that provides two access methods: web version and official website. The web version is convenient and efficient, and can be used without installation; the official website provides comprehensive product information, download resources and support services. Whether individuals or corporate users, they can easily obtain and analyze massive data through DeepSeek to improve work efficiency, assist decision-making and promote innovation.

According to news on May 31, blogger @ibinguniverse broke the news today that the Chinese version of Samsung Galaxy S24 series mobile phones will support Google search. The blogger did not disclose the specific launch time. According to Samsung’s previous introduction, the Samsung Galaxy S24 series has been equipped with many high-level AI capabilities, AI-based practical functions such as input, translation, recorder, notes, and cameras, to provide users with a more convenient and efficient comprehensive experience. Different from the overseas version, most of the AI functions of the Samsung Galaxy S24 series are provided by domestic manufacturers, such as Baidu. Previously reported, Galaxy AI deeply integrates multiple capabilities of Baidu Wenxin large model, which can provide end-side enabled call and translation functions, as well as intelligent summary brought by generative AI.

The ThinkPHP entry file is the first PHP file executed when the framework starts. It is located in the project root directory, usually index.php. It is responsible for initializing the framework, loading configuration files and routing requests, including defining root directory constants, introducing core files, creating App instances and starting the application. As a key part of the framework startup, the entry file is responsible for initializing the environment, loading classes and routing requests, and finally starts the application to process the request and return a response.

On April 16, CNMO learned that Baidu founder and CEO Robin Li declared at the Create2024 Baidu AI Developer Conference that in today’s large model ecosystem, open source models will become increasingly lagging behind. He explained that Baidu's basic model Wenxin 4.0 can be flexibly tailored according to different needs in terms of effects, response speed, and inference cost to generate streamlined models suitable for various scenarios, and supports fine-tuning and postpretraining. Compared with directly using open source models, the models cut out by Wenxin 4.0 perform better at the same size and cost less with the same effect. Therefore, he predicts that open source models will fall further and further behind. In the previous Baidu financial report conference call, Robin Li revealed that Baidu Smart Cloud’s revenue in the fourth quarter reached 8.4 billion yuan, of which

This article introduces six popular AI tools, including Douyin Doubao, Wenxin Yige, Tencent Zhiying, Baidu Feipiao EasyDL, Baidu AI Studio and iFlytek Spark Cognitive Large Model. These tools cover different functions such as text creation, image generation, video editing, and AI model development. Choosing the right AI tool requires consideration of factors such as functional requirements, technical level, and cost budget. These tools provide convenient and efficient solutions for individuals and businesses in need of AI assistance.
