简体   繁体   English

使用php scandir检查文件类型不起作用

[英]Check file type using php scandir not working

I am using this bellow php to check the the kind of file saved in database, but it show everything as folder please i don't know what the problem is. 我正在使用此波纹管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';}?>

The above code will output 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';
  }
?>

Now the output is file . 现在输出是file just add ' around index.php . 只需在index.php周围添加'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM