2016-06-19 12 views
0

私はこのbellow phpを使用してデータベースに保存されているファイルの種類を確認していますが、問題が何であるか分かりません。php scandirが動作していないファイルタイプを確認してください

<?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

+0

デバッグ: 'echo'または' print_r'を使用して、各コード行の後に各変数または関数呼び出しの内容を表示します。このようにして、問題の場所を簡単に特定できます。 – Jocelyn

答えて

0
<?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の周りに'を追加してください。

関連する問題