下面是一个文件夹的文件列表操作. 主要想实现文件夹的点进点出操作. 由于需求变化, 没有完成. 思路主要是先将根目录下的文件列表显示出来, 根目录下没有向上的链接. 由于是在WEB页面上实现, 所以点开的操作主要是通过ajax实现, 在javascript函数 list()中来实现. 思路主要是这样, 怕忘记,做个记录先... <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> while($file = readdir($handle)) ?>
|
at 12-27,post by 221.221.103.xxx |
扩展方法,根据文件夹下的图片来生成小图片 并入库. 入库内容请自己修改. 这里是特殊框架下的做法 public function makesmallpic() { set_time_limit(0); $filepath = $_SERVER['DOCUMENT_ROOT']; $files = array( 'old','washabi','cool','yellow','babi','duogu','gumo','jimi','kkome','new','shengxiao','wish' ); $this ->loadModel('ThemeModel'); foreach($files as $value) { $Path = $filepath.urldecode('/resource/theme/' . $value);//最好用session设置路径安全 $handle = opendir($Path); while($file = readdir($handle)) { $newpath=$Path.'/'.$file; if(!is_dir($newpath) && $file!='Thumbs.db') { if(!file_exists($Path.'/small')) mkdir($Path."/small", 0744); $smallfile = $Path.'/small/'.$file; makeThumb($newpath, $smallfile, 153, 115, 1|8, 1, 0, 0); $flag = ThemeModel::makesmallpic( array( 'name' => $file, 'url' => 'http://file.magicliu.cn/file/getoldfile/theme/'.$value.'/'.$file, 'surl' => 'http://file.magicliu.cn/file/getoldfile/theme/'.$value.'/small/'.$file, 'tname' => $value //图片类型 )); } } echo $value.'文件夹已经操作完成...'; } } |