Home > php教程 > PHP开发 > body text

How to modify the uploaded image or file path in the UEditor editor

高洛峰
Release: 2016-12-27 09:11:58
Original
2251 people have browsed it

Use ueditor editor. The attachment is in ueditor/php/upload/ by default. My attachment address is /data/upload/ in the root directory of the website. You need to modify ueditor as follows:

Step 1: Open php /config.php Modify the image directory

return array(

    //图片目录
    'imageSavePath' => array (
        '../../../../data/upload'
    )

);
Copy after login

Step 2: Remove the relative path after uploading the image php/imageUp.php

    $info["url"]=str_replace('../../../../', '', $info["url"]);
    echo "{'url':'" . $info["url"] . "','title':'" . $title . "','original':'" . $info["originalName"] . "','state':'" . $info["state"] . "'}";
    exit;
Copy after login

Step 3: Open ueditor.config.js to modify the image path

 ,imagePath:"/"
Copy after login

Step 4: If you want to modify the image generation path or image name

Modify the image generation path in php/Uploader.class.php

    private function getFolder()
    {
        $pathStr = $this->config[ "savePath" ];
        if ( strrchr( $pathStr , "/" ) != "/" ) {
            $pathStr .= "/";
        }
        $pathStr .= date( "Ym/d" );
        if ( !file_exists( $pathStr ) ) {
            if ( !mkdir( $pathStr , 0777 , true ) ) {
                return false;
            }
        }
        return $pathStr;
    }
Copy after login

Modify the file name in Search "fileNameFormat" in ueditor.all.min.js, and then modify it according to the official documentation!


For more related articles on how to modify the UEditor editor’s custom uploaded image or file path, please pay attention to the PHP Chinese website!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template