使用PHP Scandir检查文件类型



我正在使用此波纹管php检查保存在数据库中的文件的种类,但它显示了所有内容,请显示出文件夹,我不知道问题是什么。

<?php
$path = dirname(__FILE__);
$sub_folder = scandir($path);
$num = count($sub_folder);
//$jailchillink This is the name of file saved in database replaced width index.php
    if(is_file($path.'\'.index.php)){  $codetype = 'file';}
   else if(is_img($path.'\'.index.php)){  $codetype = 'image';}
    else{ $codetype = 'folder';}?>

上述代码将输出folder

<?php
  $path = dirname(__FILE__);
  $sub_folder = scandir($path);
  $num = count($sub_folder);
  //$jailchillink This is the name of file saved in database replaced  width index.php
  if(is_file($path.'\'.'index.php')){
     echo $codetype = 'file';
  }else if(is_img($path.'\'.'index.php')){
    echo $codetype = 'image';
  }else{ 
    echo $codetype = 'folder';
  }
?>

现在输出为file。只需在index.php附近添加'

最新更新