• ueditor整合到thinkPHP里


    在这里插入图片描述
    在这里插入图片描述

    
    
    
    namespace app\ueditor\controller;
    
    
    use think\Controller;
    
    class Ueditor extends Controller
    {
        //首页
        public function upload(){
            //header('Access-Control-Allow-Origin: http://www.baidu.com'); //设置http://www.baidu.com允许跨域访问
            //header('Access-Control-Allow-Headers: X-Requested-With,X_Requested_With'); //设置允许的跨域header
            date_default_timezone_set("Asia/chongqing");
            error_reporting(E_ERROR);
            header("Content-Type: text/html; charset=utf-8");
    
            //同样的,修改为绝对路径
            $current_path = __DIR__.'/';
            $CONFIG = json_decode(preg_replace("/\/\*[\s\S]+?\*\//", "", file_get_contents($current_path."config.json")), true);
    //		$action = $_GET['action'];
            $action = request()->param('action');
    
            switch ($action) {
                case 'config':
                    $result =  json_encode($CONFIG);
                    break;
    
                /* 上传图片 */
                case 'uploadimage':
                    /* 上传涂鸦 */
                case 'uploadscrawl':
                    /* 上传视频 */
                case 'uploadvideo':
                    /* 上传文件 */
                case 'uploadfile':
                    $result = include("action_upload.php");
                    break;
    
                /* 列出图片 */
                case 'listimage':
                    $result = include("action_list.php");
                    break;
                /* 列出文件 */
                case 'listfile':
                    $result = include("action_list.php");
                    break;
    
                /* 抓取远程文件 */
                case 'catchimage':
                    $result = include("action_crawler.php");
                    break;
    
                default:
                    $result = json_encode(array(
                        'state'=> '请求地址出错'
                    ));
                    break;
            }
    
            /* 输出结果 */
            if (isset($_GET["callback"])) {
                if (preg_match("/^[\w_]+$/", $_GET["callback"])) {
                    echo htmlspecialchars($_GET["callback"]) . '(' . $result . ')';
                } else {
                    echo json_encode(array(
                        'state'=> 'callback参数不合法'
                    ));
                }
            } else {
                echo $result;
            }
        }
    
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76

    在这里插入图片描述
    在这里插入图片描述

  • 相关阅读:
    Python潮流周刊#9:如何在本地部署开源大语言模型?
    推荐几个高质量的软件测试实战项目
    C++:详细的说明智能指针的使用以及底层实现,以及删除器和包装器的使用
    Nacos的介绍和使用Docker、MySQL持久化挂载安装
    【JUC并发编程--java线程】
    IO源码笔记
    [附源码]计算机毕业设计springbootSwitch交流平台
    学习Bootstrap 5的第九天
    Qt自定义标题栏
    微积分 - 隐函数求导的应用
  • 原文地址:https://blog.csdn.net/qq_21810059/article/details/134532692