使用 KindEditor 编辑器PHP语言本地上传图片提示错误

原创 小智  2020-11-29 21:57  阅读 3,201 次

KindEditor 是一套开源的在线可视化HTML编辑器,主要用于让用户在网站上获得所见即所得编辑效果,开发人员可以用 KindEditor 把传统的多行文本输入框(textarea)替换为可视化的富文本输入框。 KindEditor 使用 JavaScript 编写,可以无缝地与 Java、.NET、PHP、ASP 等程序集成,比较适合在 CMS、商城、论坛、博客、Wiki、电子邮件等互联网应用上使用。

做网站开发的程序员们对 Kindeditor 编辑器并不陌生的,它是一款非常强大的编辑器,轻量级的。结合纯 JQuery+CSS 写成的,部署环境起来非常的简单方面快捷。但操作过程中经常会遇到一些问题。今天就介绍 Windows 系统 PHP 环境内,使用 PHP 程序语言的 KindEditor HTML编辑器,用“本地上传”图片到服务器时,提示“PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP”上传错误的解决方法。

上传错误

PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Services_JSON has a deprecated constructor in D:\wwwroot\wuhan\editor\php\JSON.php on line 115

PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Services_JSON_Error has a deprecated constructor in D:\wwwroot\wuhan\editor\php\JSON.php on line 781

PHP Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Services_JSON_Error has a deprecated constructor in D:\wwwroot\wuhan\editor\php\JSON.php on line 795

KindEditor编辑器上传图片错误

原因分析

JSON.php中构造函数与class名相同,发现是 PHP7 环境的兼容性问题,PHP7 不再支持与其类名相同的方法名作为构造函数名。如果使用和类名相同的方法名会报 DEPRECATED 级别的错误,提示在未来版本中会彻底抛弃类同名方法作为构造函数。但程序仍然会正常执行。

解决PHP7环境使用 KindEditor 编辑器本地上传图片错误的问题

解决方法:使用__construct作为构造函数的方法名。

步骤:找到 JSON.php 文件( \editor\php\JSON.php ),将 Services_JSON 方法,改为 __construct

133行Services_JSON 方法,改为 __construct

783、797行Services_JSON_Error 方法,改为 __constructt

解决KindEditor上传图片错误的问题

注意事项
  • 图片文件保存目录路径,editor 下一定要有 attached 文件夹,否则上传不了,会出现空白内容
  • 下载的 editor 没有 attached 文件夹,要自己建立该文件夹
  • upload_josn.php文件,下载包里有,不用更改即可使用,但是一定要有attached文件夹
本文地址:http://aszhi.com/web/77.html
关注我们:请关注一下微信号:扫描二维码爱思智前端的微信号
版权声明:本文为原创文章,版权归 小智 所有,欢迎分享本文,转载请保留出处!

发表评论


表情