zoukankan      html  css  js  c++  java
  • php 遍历文件夹及文件,获取文件名和文件路径存入数据库中

    <?php
    header("Content-Type:text/html; charset=gbk");
    require('../../include/connect.php');    //连接数据库
    mysql_query("set names gbk");
     function file_list($path)  
        {  
            if ($handle = opendir($path))//打开路径成功  
            {  
                while (false !== ($file = readdir($handle)))//循环读取目录中的文件名并赋值给$file  
                {  
                    if ($file != "." && $file != "..")//排除当前路径和前一路径  
                    {  
                        if (is_dir($path."/".$file))  
                        {  
        //                    echo $path.": ".$file."<br>";//去掉此行显示的是所有的非目录文件  
                            file_list($path."/".$file);  
                        }  
                        else  
                        {  
                            echo $path."/".$file."<br>";
    $insert_sql = "insert into file values(NULL,'".$file."','".$path."','beizhu',1,0,now(),'shanchuanren','shenheren',now(),'".$path."s/".$file."')";  
    //mysql_query($insert_sql);  
                        }  
                    }  
                }  
            }  
        }
    $path = ".";
    file_list($path);
    ?>

  • 相关阅读:
    Mongodb在windows下的安装和启动
    git操作的常用命令
    删除smartygit的配置文件
    注册树模式
    关于js的一些基础知识点
    关于mysql的初步学习 (五)
    关于mysql的初步学习 (四)
    关于mysql的初步学习 (三)
    关于mysql的初步学习 (二)
    关于数据库建表时的有趣实例--关键字重复
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3297187.html
Copyright © 2011-2022 走看看