首先我们要知道帝国cms系统设置中的“附件地址”设置是返回每次上传后的路径,而不是附件上传的目录路径。所以无论你设置成什么,附件都还是上传到d/file/下,下面我的站长站教大家帝国CMS修改默认图片附件上传路径方法。

帝国CMS修改附件上传路径教程
一:先在系统设置中将“附件地址”一项修改为自己想要的地址,这里以 /wdzzz/ 为例,这样每次上传后返回的路径就显示为/wdzzz/123.jpg
二:修改 /e/class/connect.php 文件,搜索“//返回附件目录”,修改位置在2964行左右。
//返回附件目录
function ReturnFileSavePath($classid,$fpath=''){
global $public_r,$class_r;
$fpath=$fpath||strstr(','.$fpath.',',',0,')?$fpath:$public_r['fpath'];
$efileurl=eReturnFileUrl();
if($fpath==1)//p目录
{
$r['filepath']='d/file/p/';
$r['fileurl']=$efileurl.'p/';
}
elseif($fpath==2)//file目录
{
$r['filepath']='d/file/';
$r['fileurl']=$efileurl;
}
else
{
if(empty($classid))
{
$r['filepath']='d/file/p/';
$r['fileurl']=$efileurl.'p/';
}
else
{
$r['filepath']='d/file/'.$class_r[$classid][classpath].'/';
$r['fileurl']=$efileurl.$class_r[$classid][classpath].'/';
}
}
return $r;
}将文件中所有 d/file/ 替换为 wdzzz/ 值。
//返回附件目录
function ReturnFileSavePath($classid,$fpath=''){
global $public_r,$class_r;
$fpath=$fpath||strstr(','.$fpath.',',',0,')?$fpath:$public_r['fpath'];
$efileurl=eReturnFileUrl();
if($fpath==1)//p目录
{
$r['filepath']='wdzzz/p/';
$r['fileurl']=$efileurl.'p/';
}
elseif($fpath==2)//file目录
{
$r['filepath']='wdzzz/';
$r['fileurl']=$efileurl;
}
else
{
if(empty($classid))
{
$r['filepath']='wdzzz/p/';
$r['fileurl']=$efileurl.'p/';
}
else
{
$r['filepath']='wdzzz/'.$class_r[$classid][classpath].'/';
$r['fileurl']=$efileurl.$class_r[$classid][classpath].'/';
}
}
return $r;
}三:另外还需要手动创建 wdzzz文件夹,不然后台刷新会显示目录不存在。

