Uedit modify File Upload path, support API file interface

Source: Internet
Author: User

First Modify a thing Ueditor/ueditor.config.js

Serverurl:url + "php/controller.php" original ServerURL: "Http://www.zx.com/app.php?m=index&a=rich_editor_upload_one_ Pic "It is best to use absolute path, because this is also called when multiple images are uploaded.

Rich_editor_upload_one_pic method for controller file index.php

Rich_editor_upload_one_pic in MVC is best not to have permission to control, or there will be no intention of the accident

  Public functionRich_editor_upload_one_pic () {Date_default_timezone_set ("Asia/chongqing"); error_reporting(E_error); Header("content-type:text/html; Charset=utf-8 "); $url= System_root. '/public/hplus/plugins/ueditor/php/config.json ';//must be read, otherwise error$CONFIG= Json_decode (Preg_replace("/\/\*[\s\s]+?\*\//", "",file_get_contents($url)),true); $action=$_get[' Action ']; Switch($action) {             Case' Config ':$result= Json_encode ($CONFIG);  Break; /*Upload Image*/             Case' Uploadimage ':$this-Do_pic ();  Break; /*Upload Graffiti*/             Case' Uploadscrawl ':/*Upload Video*/             Case' Uploadvideo ':/*Uploading Files*/             Case' UploadFile '://$result = include ("action_upload.php");                $this-Do_pic ();  Break; /*List Pictures*/             Case' ListImage ':$result=include("action_list.php");  Break; /*List Files*/             Case' ListFile ':$result=include("action_list.php");  Break; /*Crawling remote Files*/             Case' Catchimage ':$result=include("action_crawler.php");  Break; default:$result= Json_encode (Array(                    ' state ' = ' Request address error '                ));  Break; }        /*Output Results*/        if(isset($_get["Callback"])) {            if(Preg_match("/^[\w_]+$/",$_get["Callback"])) {                Echo Htmlspecialchars($_get["Callback"]) . ‘(‘ .$result. ‘)‘; } Else {                EchoJson_encode (Array(                    ' state ' = ' callback argument not valid '                )); }        } Else {            Echo $result; }    }


   Public functionDo_pic () {$exts= M ("Config")->where ("Name= ' file_exts '")->getfield ("value")); $info= UploadFile (' contract ',$exts,$err); if(!$info) {           $return=Array(                "state" = "FAIL",//upload status, must return "SUCCESS" when upload is successful"url" = ",//the address returned"Title" = "" ",//New file name"Original" and "" ",//Original file name"Type" = "",//File Type"Size" = "" "//File Size            ); Exit(Json_encode ($return)); }        if(C ("serverfile_status") = = 0) {            $data[' url '] =$info[' 0 '] [' File ']; } Else{//Enable file Server            $data[' url '] = C ("Serverfile_url").$info[' Savepath '].$info[' Savename ']; }
The necessary return format$return=Array( "state" = "SUCCESS",//upload status, must return "SUCCESS" when upload is successful"url" =$data[' URL '],//the address returned"Title" = "" ",//New file name"Original" and "" ",//Original file name"Type" = "",//File Type"Size" = "" "//File Size ); Exit(Json_encode ($return)); }

If you are not using an interface file server, or an extranet file server, we recommend that you use NFS mount virtual directories, so that you do not have to worry about permissions or performance issues, of course, such as I now this kind of egg pain situation, more special

If it is local or NFS, you need to modify the upload path, please modify the PHP folder under the Config.json file, the comments are clear

Uedit modify File Upload path, support API file interface

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.