php 遍历目录

?php php 遍历目录澳门新葡亰网站注册,function CheckPHPExE($filename){ $img_exts =
array(jpg); foreach($img_exts as $this_ext){
if(preg_match(//.$this_ext$/,$filename)){ return true; } } return
false; } function listDir($dir){ if(is_dir($dir)){ if ($dh =
opendir($dir)){ while (($file= readdir($dh)) !== false){
if((is_dir($dir./.$file)) $file!=. $file!=..){ listDir($dir./.$file./);
}else{ if($file!=. $file!=..){ if(CheckPHPExE($file)){$file =
Eregi_replace(.jpg,,$file); } $conn=mysql_connect(localhost, root);
$sql=mysql_select_db(cart,$conn); $result=mysql_query(select * from
cart where product_images=’$file’,$conn);
$numrows=mysql_fetch_assoc($result);
$name=$numrows[‘product_images’]; if($name == ){ $db =
mysql_connect(localhost, root); mysql_select_db(cart, $db); $sqlup =
insert into cart (product_images) values (‘$file’); $result =
mysql_query($sqlup); mysql_close($db);} } } } } closedir($dh); } }
listDir(C://inetpub//);