To modify the Dedecms picture upload path naming rules method steps

Source: Internet
Author: User
Tags ord

Recently in the Web site root directory, found that the Ma Haixiang blog site already has thousands of folders, where the light picture folder accounted for nearly half. This is mainly due to the DEDECMS background management system picture attachment is automatically saved by the day, only have pictures or near upload, will be a day to generate a folder, a long time, in the allimg will generate a large number of folders, the transfer and management of the site is really inconvenient!

So in this I modify the method of Ma Haixiang blog, also here to share with you, how I modified the site of the picture folder is only saved by the name of the year, so that the site upload pictures and attachments every month only generated and saved in a folder:

1, directly use the background to set the method of saving by month

Open dedecms background, System > System basic Parameters > Accessories settings, there is a setting item "Attachment save form (by data function date parameter)", the default value is: Ymd is the meaning of the month and day, change him to the YM is to save the attachment by the month.

According to my test on Ma Haixiang blog site, this function seems to be not perfect, only in the FCK upload function upload files or automatically generated thumbnails can play a role. On this point you can test it in the background to know. "Upload" The new file when the date is automatically generated by month and day storage. If you want to completely solve this problem, you need to carefully look at the Ma Haixiang blog to share the 2nd, 3 steps.

2, the use of "background upload", by the date of the method of saving

Login to the Web site server, open the folder under the root directory of the Web site, the file open path is: dede/media_add.php (note: Dede, for the DEDECMS default background path), found:

[table=95%,,, 0] [TR] [TD]d pa th =m Yda te ( " Ymd " Dpath=mydate ("Ymd", uptime); [/TD] [/TR] [/table]
Change to:
[table=95%,,, 0] [TR] [TD]d pa th =m Yda te ( " Ym " dpath=mydate ("ym", uptime); [/TD] [/TR] [/table]

the 5.7 version of DEDECMS is:
   d pa th =m Yda te ( " Ymd " Dpath=mydate ("Ymd", uptime);
Change to:
   d pa th =m Yda te ( " Ym " dpath=mydate ("ym", uptime);

This allows you to upload image files in the background of the site will be stored by the month.

3. When using "Download remote Picture", the method of storing by month and year

Login to the Web site server, open the folder under the root directory of the Web site, the file open path is: dede/inc/inc_archives_functions.php (note: Dede, for the DEDECMS default background path), found:

[table=95%,,, 0] [TR] [TD]imgUrL= Imgurl=cfg_uploaddir. ' /’. MyDate ("Ymd", Time ()); [/TD] [/TR] [/table]
Switch
[table=95%,,, 0] [TR] [TD] imgUrL=imgurl=cfg_uploaddir. ' /’. MyDate ("YM", Time ()); [/TD] [/TR] [/table]

the 5.7 version of DEDECMS is:
   i mg ur l= Imgurl=cfg_uploaddir. ' /‘. MyDate ("Ymd", Time ());
Switch
   imgUrL=imgurl=cfg_uploaddir. ' /‘. MyDate ("YM", Time ());

This way you later in the background download remote pictures will be stored by the month, the same image localized attachments will be saved by the month.

According to the above 3 steps, you can ensure that the site in the addition of pictures or upload a new file, the save path is the name of the month and year of storage. But also do collect friends reflect that, in the collection of articles or pictures, will still find that the storage files are named according to the date of the year, on this, you will follow the 4th step below to revise again.

4, the acquisition of resources when remote resources localization, according to the method of storage

This step is to modify the remote resource localization automatically generated folder naming when collecting resources. Login to the website's server, open the folder under the root directory of the Web site, the file open path is: include/dedecollection.class.php,5.7 version about 637 lines, found:

TIMEDIR="C".MYDATE("YMD",TIMe ( ) ) ; change : timedir= "C".  MyDate ("Ymd", Time ()); Instead: Timedir = "C". MyDate ("YM", Time ());

This way, when you collect resources, remote resources localize automatically generated folders when they are stored.

This article for Ma Haixiang Blog original article, if want to reprint, please indicate the original site from the http://www.mahaixiang.cn/CMS/261.html, annotated source, otherwise, no reprint; Thank you!

To modify the Dedecms picture upload path naming rules method steps

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.