今天一个客户的网站在后台传图片的时候,发现织梦DEDECMS生成的文件夹是按天生成的,只要传了图片就会自动建立个年月日的文件,centos系统下,都是随便排序的,很难找到对应文件夹,所以查阅很多资料才发现:dir()和scandir()原来是有区别的,故整理如下,希望可以帮到有需要的小伙伴!

    一、文件管理器

    修改/dede/templets/file_manage_main.htm

$dh=dir($inpath);
    $ty1="";
    $ty2="";
    $files=$dirs=array();
    while(($file=$dh->read())!==false)

    改为

$dh=scandir($inpath);
    $ty1="";
    $ty2="";
    $files=$dirs=array();
    foreach($dhas$file)

    删掉

    $dh->close();

    

二、模板文件

    修改/dede/templets/templets_default.htm

<?php
    $dh=dir($templetdird);
    while($filename=$dh->read())
    {
    if(!preg_match("#\.htm#",$filename))continue;
    $filetime=filemtime($templetdird.'/'.$filename);
    $filetime=MyDate("Y-m-dH:i",$filetime);
    $fileinfo=(isset($fileinfos[$filename])?$fileinfos[$filename]:'未知模板');
    ?>

    改为

<?php
    $files=scandir($templetdird);
    foreach($filesas$filename)
    {
    if(!preg_match("#\.htm#",$filename))continue;
    $filetime=filemtime($templetdird.'/'.$filename);
    $filetime=MyDate("Y-m-dH:i",$filetime);
    $fileinfo=(isset($fileinfos[$filename])?$fileinfos[$filename]:'未知模板');
    ?>

    

三、缩略图

    修改/include/dialog/select_images.php

$dh=dir($inpath);
    $ty1="";
    $ty2="";
    while($file=$dh->read())

    改为

$dh=scandir($inpath);
    $ty1="";
    $ty2="";
    foreach($dhas$file)

    删掉

    $dh->close();