我与改革开放同岁 發表於 2023-10-23 00:00:00

解析织梦DedeCMS图片按月存放的实现方法

<p>
        <span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>打开目录include里面的dedecollection.class.php </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><strong style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>代码如下: </strong></p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <p class="right">
                <span><u>复制代码</u></span></p>
        <p>
                代码如下:</p>
</div>
<p class="msgborder" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        //获得下载媒体的随机名称 <br>
        function GetRndName($url,$v) <br>
        { <br>
        global $cfg_image_dir,$cfg_dir_purview; <br>
        $this-&gt;mediaCount++; <br>
        $mnum = $this-&gt;mediaCount; <br>
        $timedir = "c".MyDate("ym(修改些处,去掉原有的d即可按月存放,同理以你自己喜欢的来设定吧)",time()); <br>
        //存放路径 <br>
        $fullurl = preg_replace("/\/{1,}/","/",$cfg_image_dir."/"); <br>
        if(!is_dir($GLOBALS['cfg_basedir']."/$fullurl")) <br>
        { <br>
        MkdirAll($GLOBALS['cfg_basedir']."/$fullurl",$cfg_dir_purview); <br>
        } <br>
        $fullurl = $fullurl.$timedir."/"; <br>
        if(!is_dir($GLOBALS['cfg_basedir']."/$fullurl")) <br>
        { <br>
        MkdirAll($GLOBALS['cfg_basedir']."/$fullurl",$cfg_dir_purview); <br>
        } </p>
<p>
        <br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><strong style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>附后台及远程下载存放方法: </strong><br><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>打开后台目录dede(默认为dede,如果你改过请找到对应的文件夹). 打开文件 media_add.php , 找到如下代码:(默认的在第25行) </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><font color="#ff0000" style='line-height: 25.2px; font-size: 14px; font-family: tahoma, arial, "Microsoft YaHei";'>$dpath = MyDate(“ymd”,$uptime); 修改为: <br>
        $dpath = MyDate(“ym”,$uptime); 这样你在以后后台上传文件时就会按月存放了. </font><br><br><strong style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>“下载远程<u>图片</u>”按月存放 </strong><br><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>同样在后台, 展开文件 dede/inc/inc_archives_functios.php 找到如下代码:(默认的在第96行) </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><font color="#ff0000" style='line-height: 25.2px; font-size: 14px; font-family: tahoma, arial, "Microsoft YaHei";'>$imgUrl = $cfg_uploaddir.’/’.MyDate(“ymd”,time()); 修改为: <br>
        $imgUrl = $cfg_uploaddir.’/’.MyDate(“ym”,time()); 以后图片本地化的附件就会按月保存</font></p>
頁: [1]
查看完整版本: 解析织梦DedeCMS图片按月存放的实现方法