Baidu ueditor editor picture upload directory modification Settings tutorial

Source: Internet
Author: User
Tags rand

Method one, by modifying PHP to change the Ueditor editor picture upload directory

Ueditor image upload needs to set up their own function to normal. At the same time, as shown in the following picture, the image upload plug-in "online management", "Picture search" and other meaningless functions, you need to eradicate manually.


Also, under normal circumstances, the editor's picture storage directory, upload directory is one, should not give the user manual selection, but also need to manually delete.

The modification process is as follows:

1, first open (ueditor1_3_6-utf8-php root directory) \php\config.php the code to the following:

<?php
Return Array (
Image upload allowed storage directory
' Imagesavepath ' => Array (
' Upload '
)
);
At the same time, create a upload folder manually under \php\ (ueditor1_3_6-utf8-php root), which ueditor the program will not be created itself.

If you do not create it yourself, you will get an error. This upload corresponds to the ' upload ' of the above code. According to their needs, can be changed to "./upload/aa" and other paths, at the same time need to be in the corresponding path, a new directory and folder.

At this point, Ueditor 1.3.x, the Rich text editor, has been able to upload files without making any changes to ueditor.config.js, like the official document.

2, however, the Ueditor 1.3.x default is to upload a picture, create a new folder of the current date, and then name a timestamp to save the picture file.

If we need to make changes to this save rule, especially if some Web sites want to name the file on the server with the user name. Modifications to the (ueditor1_3_6-utf8-php root) \php\uploader.class.php are required at this time. After the 103th line of this file is the final upload, the rules for naming the file.


As above, is the requested upload picture, add a "id_" prefix. This can be replaced by $_session["user name" or something.

Specifically, you can also direct the GetFolder () function of this file to modify, so that it does not create a new current date of the folder, in which to put files, etc., modified to belong to their own upload rules. The GetFolder () function is at the end of this Uploader.class.php.

3, finally, but also to remove the "online management", "Picture Search", "Choose the image Storage directory" and other meaningless functions. This is modified in the (ueditor1_3_6-utf8-php root directory) \dialogs\image\image.html.

The following figure, 第16-19 with HTML comments, you can remove the "online management", "Picture Search" two features.

To "Choose the picture Storage directory" Out, must take, will be the 60th line, Div with style= "display:none" to hide it, rather than direct comments, directly annotated words. Because its Drop-down list is generated by JavaScript. Although it does not affect functionality, JavaScript errors can occur. It's not good.

In the end, this PHP version of the Ueditor 1.3.x functionality is modified as follows:

Method Two, find the Baidu Editor directory Config.json configuration file Open/Baidu Editor directory/php/config.json


/* Upload Picture configuration Item * *
"Imageactionname": "Uploadimage",/* Execute the action name of the uploaded image/*
"Imagefieldname": "Upfile", * * submitted picture form name * * *
"Imagemaxsize": 2048000,/* Upload size limit, Unit b * *
"Imageallowfiles": [". png", ". jpg", ". jpeg", ". gif", ". bmp"],/* Upload picture format display * *
' Imagecompressenable ': true,///compression of the picture, default is True/*
"Imagecompressborder": 1600,/* picture compression maximum edge limit * *
"Imageinsertalign": "None", * * Insert the picture floating mode * *
"Imageurlprefix": "",/* Image access Path prefix * *
"Imagepathformat": "/upfile/{yyyy}/{mm}/{dd}/{time}{rand:6}",/* Upload save path, you can customize the save path and file name format * *
/* {filename} will be replaced by the original filename, configure this need to pay attention to the Chinese garbled problem * *
/* {RAND:6} will replace the random number, followed by the number of random number of digits * *
/* {time} will be replaced with a timestamp * *
/* {YYYY} will be replaced by four-bit year * *
/* {YY} will be replaced by two-bit year * *
/* {mm} will be replaced by two-digit month * *
/* {DD} will be replaced with two-digit date.
* * {HH} will be replaced by two-hour/
/* {II} will be replaced by two-bit minutes */
/* {SS} will be replaced by two-bit seconds * *
/* Illegal characters \: *? "< > | */
* * Please look at the online document: fex.baidu.com/ueditor/#use-format_upload_filename * *


Just modify the "Imagepathformat": "/upfile/{yyyy}/{mm}/{dd}/{time}{rand:6}",/* Upload the save path, you can customize the save path and file name format * * Can be, here is a small edit changed.

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.