2016-06-19 1 views
0

이 벨로우 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 주위에 '을 추가하기 만하면됩니다.

관련 문제