php 遍历文件夹及文件,获取文件名和文件路径存入数据库中
来源:互联网 发布:excel数据分析方法五种 编辑:程序博客网 时间:2024/05/16 03:56
<?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);
?>
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);
?>
0 0
- php 遍历文件夹及文件,获取文件名和文件路径存入数据库中
- php 遍历文件夹及文件,获取文件名和文件路径存入数据库中
- 遍历指定文件下所有的文件夹和文件的路径,文件名,修改日期,类型
- windows C++ 遍历目录,获取文件名和文件路径
- windows C++ 遍历目录,获取文件名和文件路径
- 用php将某个 文件夹下的所有文件的 文件名存入mysql数据库中
- 获取OpenFileDialog的文件名和文件路径
- 输出文件夹中java文件的路径和文件数目
- PHP 中获取文件名及路径
- PHP 中获取文件名及路径
- PHP 中获取文件名及路径
- PHP 中获取文件名及路径
- PHP 中获取文件名及路径
- 遍历文件夹和文件
- ASP.NET中遍历文件夹和文件
- bash中获取文件路径和文件命的函数
- C#中OpenFileDialog获取文件名和文件路径的常用方法
- C#中OpenFileDialog获取文件名和文件路径的常用方法
- C语言socket编程的分包和粘包的有关问题解决
- JQuery的 $.getJSON解析本地或者服务器的json文件
- CentOS 7 网络配置
- springboot中webjars的打包与调用
- 7、字符串的输入与输出scanf、printf、cin、cout、gets、puts
- php 遍历文件夹及文件,获取文件名和文件路径存入数据库中
- Java基础学完了?来!复习(必看干货!)请认真看哦!
- apache 302重定向
- 文件相关工具类
- Django Rest Framework - 异常 、返回值处理 与 分页实现
- sys/cdefs.h: No such file or directory
- 多态
- 64-bit Tips
- 【Spring 核心】AOP 面向切面编程