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. 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 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\... 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] 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
Archived
This topic is now archived and is closed to further replies.