先说下偶的需求,我在做一个实验报告提交系统,现在需要统计文件夹sy中每个学生提交的实验报告(doc文档)的份数并显示在网页上,要怎么做呢。大牛们帮帮忙,急用呀

解决方案 »

  1.   

    使用遍历函数把sy文件夹遍历一遍就可以统计份数了,同时可以获取文件名并显示,具体可以看看php手册查查关于文件的操作那部分,例子比较详细,实例化。
      

  2.   

    展示可以这样写
    foreach (glob("sy/*.doc") as $filename) {
        echo $filename  . "\n";
    }
    下载的话可以搜索一下相关代码
      

  3.   

    自己去查php函数,遍历文件夹的文件,计数,获取文件后缀名,或者像楼上说的用正则匹配文件名
      

  4.   

    <?php
    $count=0;
    header("content-type:text/html;charset=gb2312");
    $file_path = $_SERVER['DOCUMENT_ROOT']."/sy";
    find_files($file_path);
    echo "文件份数".$count;
    function find_files($file_path){
    if(is_dir($file_path)){
    if ($dh = opendir($file_path)) {
    while (($file_name = readdir($dh)) !== false) {
    if($file_name!="."&&$file_name!=".."){
    if(filetype($file_path.$file_name)!="dir"){
    $count+=1;
    echo "filename:$file_path.$file_name";
    }else{
    find_files($file_path.$file_name."/");
    }
    }
    }
    closedir($dh);
    }
    }
    }
    ?>
      

  5.   

    那你的doc文件是如何分步的?每个学生一个文件夹还是?最好截个图出来。