The_Holy_One Posted May 25, 2006 Share Posted May 25, 2006 [code]$dir = ".";if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { $id = filetype($file); echo "$id: $datei"; echo "$file <br />"; } closedir($dh); }}[/code]As long my $dir is "." all filetypes will be correctly shown like this:dir: . dir: .. file: 28448513943d2cf0fb5908.gif dir: backup file: CIMG0117.JPG But if i change the directory for example "./backup" or ".\backup" i get a lot of failure messages and i have really NO IDEA Why !, the links seems to work, otherwise it wouldnt print out the list at the bottom after the failure message. What i am doing wrong ? if i comment //$id = filetype($file); i get the whole list, even from subfolders but if i try to get there "type" it mess up.btw. i want code me a function which print me out DIR with $dir and $flag=0; or FILE's with $dir and $flag=1; I am happy for everbody who helps me. Quote Link to comment https://forums.phpfreaks.com/topic/10435-filetype-in-root-ok-in-subfolders-a-mess/ Share on other sites More sharing options...
shocker-z Posted May 25, 2006 Share Posted May 25, 2006 try using exact paths like /var/www/testelse you could use ../backup make sure 2 .'s as 1 normaly executes a files..RegardsLiam Quote Link to comment https://forums.phpfreaks.com/topic/10435-filetype-in-root-ok-in-subfolders-a-mess/#findComment-38912 Share on other sites More sharing options...
The_Holy_One Posted May 25, 2006 Author Share Posted May 25, 2006 Still dont work, even with hardlinks like C:\abc\... Quote Link to comment https://forums.phpfreaks.com/topic/10435-filetype-in-root-ok-in-subfolders-a-mess/#findComment-38929 Share on other sites More sharing options...
The_Holy_One Posted May 25, 2006 Author Share Posted May 25, 2006 I found a better Solution:[code] function filelist($startdir) { //list the directory/file names that you want to ignore global $directorylist; //initialize global array $ignoredDirectory[] = "."; $ignoredDirectory[] = ".."; $ignoredDirectory[] = "_vti_cnf"; if (is_dir($startdir)) { if ($dh = opendir($startdir)) { while (($file = readdir($dh)) !== false) { if (!(array_search($file,$ignoredDirectory) > -1)) { $directorylist[$startdir . $file]['name'] = $file; $directorylist[$startdir . $file]['path'] = $startdir; $directorylist[$startdir . $file]['typ'] = filetype($startdir . $file); } } } closedir($dh); } return($directorylist); } $files = filelist($_SESSION['current_dir']."/"); // call the function if ($files != ""){ foreach ($files as $list) {//print array if ($list['typ'] == "dir"){ $dirname = $list['name']; echo "<a href='?dir=$dirname'>".$list['name']."</a><br />"; } } } else { echo ""; }[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10435-filetype-in-root-ok-in-subfolders-a-mess/#findComment-38956 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.