PHP combined Ueditor and modify the image upload path method

Source: Internet
Author: User
Using the Ueditor Editor, the attachment default in the ueditor/php/upload/, but everyone's attachment address of the default path is not this, need to modify the Ueditor, how to do it, the following we will explain in detail below

Objective

When using the Ueditor editor, generally we need to modify the default image upload path, the following is my collation of the modified location and method for everyone to refer to.

Operation

Ueditor PHP version itself comes with a set of upload program, we can find the configuration file on this basis to modify it. Configuration file Location:

ueditor/php/config.json

The contents are as follows:

/* Front-end communication-related configuration, comments allow only multi-line */{/* Upload picture Configuration items */"Imageactionname": "Uploadimage",/* Perform the action name of the upload picture */"Imagefieldname": " Upfile ",/* submitted picture form name */" imagemaxsize ": 2048000,/* Upload size limit, Unit B */" imageallowfiles ": [". png ",". jpg ",". jpeg ",". gif ",  ". bmp"],/* Upload image format display */"imagecompressenable": true,/* whether to compress the picture, the default is True */"Imagecompressborder": 1600,/* picture compression longest edge limit */ "Imageinsertalign": "None",/* Insert Picture floating way */"Imageurlprefix": "",/* Picture access Path prefix */"Imagepathformat": "/ueditor/php/upload /image/{yyyy}{mm}{dd}/{time}{rand:6} ",/* Upload save path, you can customize save path and file name format */*/* * {filename} will be replaced with the original file name, configure this requires attention to Chinese garbled problem *  /* * {rand:6} will be replaced with a random number, followed by a random number of digits */* * {time} will be replaced by a timestamp */* {YYYY} will be replaced by four-bit year                */*/* {YY} will be replaced by two-bit year */*/* {mm} will be replaced with two-digit month */*/* * DD} will be replaced by two-bit date */ "< > |        */        /* body look at the online document: fex.baidu.com/ueditor/#use-format_upload_filename *//* Doodle Picture Upload configuration item */"Scrawlactionname": "Uploadscr Awl ",/* do upload graffiti action name */" Scrawlfieldname ":" Upfile ",/* submitted picture form name */" Scrawlpathformat ":"/ueditor/php/upload/image/ {yyyy} {mm} {Dd}/{time}{rand:6} ",/* Upload save path, you can customize save path and file name format */" scrawlmaxsize ": 2048000,/* Upload size limit, Unit B */" Scrawlurlprefix ":" ",/* Image Access Path prefix */"scrawlinsertalign": "None",/* Tool upload */"snapscreenactionname": "Uploadimage",/* Execute the Uploaded action name */"SNAPSC Reenpathformat ":"/ueditor/php/upload/image/{yyyy}{mm}{dd}/{time}{rand:6} ",/* Upload save path, you can customize save path and file name format */" Snapscreenurlprefix ":" ",/* Image access Path prefix */" snapscreeninsertalign ":" None ",/* Insert Picture Floating mode */* Crawl remote Picture configuration */" Catcherlocald Omain ": [" 127.0.0.1 "," localhost "," img.baidu.com "]," catcheractionname ":" Catchimage ",/* Perform fetch action name for remote picture */" Catche Rfieldname ":" Source ",/* submitted picture List form name */" Catcherpathformat ":"/ueditor/php/upload/image/{yyyy}{mm}{dd}/{time}{rand  : 6} ",/* Upload save path, can customize save path and file name format */"Catcherurlprefix": "",/* Image access Path prefix */"catchermaxsize": 2048000,/* Upload size limit, Unit B */"catcherallowfiles": [". png", ". jpg", ". jpeg", ". gif", ". bmp"],/* Crawl picture format display */* Upload VIDEO Configuration */* "Videoactionname": "Uploadvideo",/* * Perform the action name of the uploaded video */"Videofi Eldname ":" Upfile ",/* submitted video form name */" Videopathformat ":"/ueditor/php/upload/video/{yyyy}{mm}{dd}/{time}{rand:6} ",/* Upload save path, you can customize save path and file name format */"Videourlprefix": "",/* Video access Path prefix */"videomaxsize": 102400000,/* Upload size limit, Unit B, default 100MB */"vid Eoallowfiles ": [". flv ",". SwF ",". mkv ",". avi ",". Rm ",". rmvb ",". Mpeg ",". mpg ",". Ogg ",". Ogv ",". mov ",". wmv ",". MP4 ",". WebM ",". mp3 ",". wav ",". Mid "],/* Upload video format display */* Upload file Configuration */" Fileactionname ":" UploadFile ",/* controller, perform upload view The action name of the frequency */"Filefieldname": "Upfile",/* file Form name submitted by */"Filepathformat": "/ueditor/php/upload/file/{yyyy}{mm}{dd}/{ Time}{rand:6} ",/* Upload save path, you can customize save path and file name format */" Fileurlprefix ":" ",/* File access Path prefix */" filemaxsize ": 51200000,/* Upload size limit, Unit B, Default 50MB */"fileallowfiles": [   ". png", ". jpg", ". jpeg", ". gif", ". bmp", ". flv", ". SwF", ". mkv", ". avi", ". Rm", ". rmvb", ". Mpeg", ". mpg", ". Ogg",  ". Ogv", ". mov", ". wmv", ". mp4", ". WebM", ". mp3", ". wav", ". Mid", ". rar", ". zip", ". Tar", ". Gz", ". 7z", ". bz2", ". cab", ". ISO", ". Doc", ". docx", ". xls", ". xlsx", ". ppt", ". pptx", ". pdf", ". txt", ". MD", ". Xml"],/* Upload file format display */* list specified directory Image below */"Imagemanageractionname": "ListImage",/* Perform picture management action name */"Imagemanagerlistpath": "/ueditor/php/upload/ image/",/* Specify the directory to list pictures */" imagemanagerlistsize ": 20,/* Number of files per list */" Imagemanagerurlprefix ":" ",/* Picture access Path prefix */" image Managerinsertalign ":" None ",/* Insert Picture floating way */" imagemanagerallowfiles ": [". png ",". jpg ",". jpeg ",". gif ",". bmp "],/* List of the text Item Type */* list files under the specified directory */"Filemanageractionname": "ListFile",/* Execute File Management action name */"Filemanagerlistpath": "/ueditor/php /upload/file/",/* Specify the directory to list the files */" Filemanagerurlprefix ":" ",/* File access Path prefix */" filemanagerlistsize ": 20,/* Number of files per list */" Filemanagerallowfiles ": [". png ",". jpg ",". jpeg ",". gif ",". bmp ",". flv ",". SwF ",". mkv ",". avi ",". Rm ",". rmvb ",". Mpeg ",". mpg ",". Ogg ",". O GV ",". mov ",". wmv ",". mp4 ",". WebM ",". mp3 ",". wav ",". Mid ",". rar ",". zip ",". Tar ",". Gz ",". 7z ",". bz2 ",". Cab ",". I So ",". Doc ",". docx ",". xls ",". xlsx ",". ppt ",". pptx ",". pdf ",". txt ",". MD ",". Xml "/* * listed file types */}

From the Config.json content, it is not difficult to see (all have comments, do not see the ghost->_->), almost all of the upload configuration is here. If you want to modify the upload path, you can do so by modifying the 12th line of the file.

For example, here we modify the Imagepathformat:

Copy the Code code as follows:

"Imagepathformat": "/upload/ueditor/{yyyy}{mm}{dd}/{time}{rand:6}",/* Upload save path, you can customize save path and file name format */


Save, upload, test, view source code:

As you can see, the modifications are successful.

Summarize

Upload configuration This, will be different because of the ueditor version, and slightly different, I just started in the new version also did not respond to the root-ediscovery only to find here, everyone in the changes should also pay attention to the next OH.

In addition, if you need to modify other uploads, such as video, you can also modify the file here, the rationale is the same.

The above is the entire content of this article, I hope to be able to help you learn.

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.