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);
    ?>

  • 相关阅读:
    Seafile开源私有云自定义首页Logo图片
    启动seafile报错Error happened during creating seafile admin.
    jupyter的安装和使用(python3版)
    C#学习资料
    服务编排-以docker-swarm为例讲解
    docker swarm架构图
    VMware中安装centos7
    js获取数据:类似xpath
    博客园备份python程序
    解决docker中jenkins运行磁盘满的问题
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3297187.html
Copyright © 2011-2022 走看看