php文件操作,文件夹列表,文件列表

下面是一个文件夹的文件列表操作.  主要想实现文件夹的点进点出操作. 由于需求变化, 没有完成. 思路主要是先将根目录下的文件列表显示出来, 根目录下没有向上的链接. 由于是在WEB页面上实现, 所以点开的操作主要是通过ajax实现,  在javascript函数 list()中来实现.  思路主要是这样,  怕忘记,做个记录先...

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
$filepath =  $_SERVER['DOCUMENT_ROOT'];
$Path  = $filepath.urldecode('/resource/theme');  //最好用session设置路径安全,这是我的路径
$handle  = opendir($Path);

while($file = readdir($handle))
{
 $newpath=$Path."/".$file;
  
 if(is_dir($newpath))
 {
  if($file!=".." && $file!=".")
  {
   $tree[0]['f'][] =  array(
   'name'   => $file,
   'path'   => $newpath
   );   
  }  
 }
 else
 {
  $tree[0]['l'][] =  array(
  'name'   => $file,
  'path'   => $newpath
  );
 }  
}

?>
<div id="theme" style="display:none;">
 <div id="file">
 <table width="90%" bgcolor="#FFFFFF">  
  <tr>
  <?php
  $i = 0;
  foreach($tree[0]['f'] as $value)
  { 
   $i++;  
  ?>
   <td align="left">
    <img alt="文件夹,双击打开" src="/resource/images/folder_close.gif">
    &nbsp;<?php echo $value['name']; ?>
   </td>
  <?php 
   if($i%3 == 0)
   echo '</tr><tr>';  
  }
  
  ?>
  </tr>
  
 </table>
 </div>
 <div id="pic">theme</div>
</div>
<script type="text/javascript">
<!--
 function list(name, path)
 {
  
 }
//-->
</script>

 

 



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.'文件夹已经操作完成...';
}
}
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值