favorite: 0 Time: 2013-08-23 article source: Ma Haixiang Blog Visits: 2350
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] $dpath = MyDate ("Ymd", $uptime); [/TD] [/TR] [/table]
Change to:
[table=95%,,, 0] [TR] [TD] $dpath = MyDate ("ym", $uptime); [/TD] [/TR] [/table]
The 5.7 version of DEDECMS is:
$dpath = MyDate ("Ymd", $uptime);
Change to:
$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 = $cfg _uploaddir. ' /’. MyDate ("Ymd", Time ()); [/TD] [/TR] [/table]
Switch
[table=95%,,, 0] [TR] [TD] $imgUrl = $cfg _uploaddir. ' /’. MyDate ("YM", Time ()); [/TD] [/TR] [/table]
The 5.7 version of DEDECMS is:
$IMGURL = $cfg _uploaddir. ' /‘. MyDate ("Ymd", Time ());
Switch
$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 ());
Switch
$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