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

  • 相关阅读:
    JS中解析JSON。
    对不同浏览器实现图片旋转。
    FF和IE内容不透明,字体透明。
    C# 通过身份证查询出生日期
    C# v3微信 access token 过期处理的问题
    C# 微信v3退款
    codesmith生成java类
    IOS调用WCF服务,WCF服务器进行上传图片
    安装VS 2013遇到的问题,及解决方案
    接口,个人理解
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3297187.html
Copyright © 2020-2023  润新知