视频教程上的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

Dreamweaver CS6
Visual web development tools

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor

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

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
