|
刚用CI一个星期,就碰到上传文件,怎么样让上传的文件按年月作为文件夹分开的问题,如/uploads/2009/08/eeee.jpg,现在解决了,把这个解决方案提供给大家!
找到upload的方法,如:F:\drawprize\system\libraries\Upload.php,找到方法set_upload_path,代码如:
/**
* Set Upload Path
*
* @access public
* @param string
* @return void
*/
function set_upload_path($path)
{
if (!is_dir($path) && $path!='./' && $path!='../') {
$dirname = '';
$folders = explode('/',$path);
foreach ($folders as $folder) {
$dirname .= $folder . '/';
if ($folder!='' && $folder!='.' && $folder!='..' && !is_dir($dirname)) {
mkdir($dirname);
}
}
chmod($path,0777);
}
// Make sure it has a trailing slash
$this->upload_path = rtrim($path, '/').'/';
}
完成 |
|