[英]Check file type using php scandir not working
我正在使用此波紋管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
周圍添加'
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.