织梦调用自定义字段附件类型文件的格式类型文件大小上传日期效果:
?
实现步骤
1、templetssystemchannel_addon.htm 里面要清空,只留~link~? ? ?(注意:不能留有一个空格)
2、includeextend.func.php? 最下面加入方法
function GetFileInfos($file,$type='size')
{
? ? global $cfg_basedir;
? ? $filepath = $cfg_basedir.$file;
? ? $size = filesize($filepath);
? ? $fileinfos = pathinfo($filepath);
? ? $units = array(' B',' KB',' MB',' GB',' TB');
? ? for ($i = 0; $size >= 1024 && $i < 4; $i++) $size /= 1024;
? ? if($type=='size') return round($size,2).$units[$i];
? ? if($type=='type') return $fileinfos['extension'];
? ? if($type=='name') return $fileinfos['filename'];
? ? if($type=='time') return MyDate("Y-m-d H:i:s",filemtime($filepath));
}
?
3、内容模板调用标签
名称:{dede:field.download function=GetFileInfos(@me,name)/}
类型:{dede:field.download function=GetFileInfos(@me,type)/}
大小:{dede:field.download function=GetFileInfos(@me,size)/}
时间:{dede:field.download function=GetFileInfos(@me,time)/}