视频教程上的ueditor和最新版本不太一样,今天弄了好长时间,终于可以成功上传了。现在给大家分享一下。
配置项处做一下修改,如下:<script><br />
window.UEDITOR_HOME_URL = '__ROOT__/Data/Ueditor/';<br />
window.onload = function () {<br />
window.UEDITOR_CONFIG.initialFrameWidth = 1200;<br />
window.UEDITOR_CONFIG.initialFrameHeight = 600;<br />
window.UEDITOR_CONFIG.serverUrl = "{:U(GROUP_NAME.'/Blog/upload')}";<br />
UE.getEditor('content');<br />
}<br />
<br />
</script>
upload()做了较大的修改,主要是把新版本ueditor的controller.php文件复制过来进行了一下修改。//编辑器图片上传处理<br>
public function upload () {<br>
date_default_timezone_set("Asia/chongqing");<br>
error_reporting(E_ERROR);<br>
header("Content-Type: text/html; charset=utf-8");<br>
<br>
$CONFIG = json_decode(preg_replace("/\/\*[\s\S]+?\*\//", "", file_get_contents("./Data/Ueditor/php/config.json")), true);<br>
$action = $_GET['action'];<br>
switch ($action) {<br>
case 'config':<br>
$result = json_encode($CONFIG);<br>
break;<br>
<br>
/* 上传图片 */<br>
case 'uploadimage':<br>
/* 上传涂鸦 */<br>
case 'uploadscrawl':<br>
/* 上传视频 */<br>
case 'uploadvideo':<br>
/* 上传文件 */<br>
case 'uploadfile':<br>
//$result = include("action_upload.php");<br>
import('ORG.Net.UploadFile');<br>
$upload = new UploadFile();<br>
$upload->autoSub = true;<br>
$upload->subType = 'date';<br>
$upload->dateFormat = 'Ym';<br>
if ($upload->upload('./Uploads/')){<br>
$info = $upload->getUploadFileInfo();<br>
echo json_encode(array(<br>
'url' => __ROOT__.'/Uploads/'.$info[0]['savename'],<br>
'title' => htmlspecialchars($_POST['pictitle'], ENT_QUOTES),<br>
'original' => $info[0]['name'],<br>
'state' => 'SUCCESS'<br>
));<br>
<br>
}else{<br>
echo json_encode(array(<br>
'state' => $upload->getErrorMsg(),<br>
));<br>
}<br>
break;<br>
<br>
<br>
}<br>
<br>
/* 输出结果 */<br>
if (isset($_GET["callback"])) {<br>
if (preg_match("/^[\w_]+$/", $_GET["callback"])) {<br>
echo htmlspecialchars($_GET["callback"]) . '(' . $result . ')';<br>
} else {<br>
echo json_encode(array(<br>
'state'=> 'callback参数不合法'<br>
));<br>
}<br>
} else {<br>
echo $result;<br>
}<br>
}
这样上传图片就正常了,大家试一下,如果有问题可以留言共同讨论。
AD:真正免费,域名+虚机+企业邮箱=0元

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

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Atom editor mac version download
The most popular open source editor

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
