Vertrex Posted June 29, 2012 Posted June 29, 2012 Hello to the people of HelioHost. After a long time of using your service, this is the first time I've decided to actually brighten up my dull brain. My question is simply (hopefully understandable). I am trying to write a script that enables me to read in files and directories from sub folders and then read in the data from them. Many thanks in advance. Quote
Lugus Posted June 30, 2012 Posted June 30, 2012 Hello,I found this function on the web which permits you to list all the files in a specific directory and its sub-directories. function ListFiles($dir) { if($dh = opendir($dir)) { $files = Array(); $inner_files = Array(); while($file = readdir($dh)) { if($file != "." && $file != ".." && $file[0] != '.') { if(is_dir($dir . "/" . $file)) { $inner_files = ListFiles($dir . "/" . $file); if(is_array($inner_files)) $files = array_merge($files, $inner_files); } else { array_push($files, $dir . "/" . $file); } } } closedir($dh); return $files; } } And here's how to use it: foreach (ListFiles('YOUR-DIRECTORY') as $key=>$file){ echo $file ."<br />"; } I hope it helps. Quote
Hairy DJ Posted July 1, 2012 Posted July 1, 2012 Byron has worked with RecursiveDirectoryIterator to make a search tool for file managers. I don't know how much PHP you know but I wouldn't call it a project for beginners but feel free to ask questions. http://www.eclecticdjs.com/forum/viewtopic.php?f=15&t=934http://www.eclecticdjs.com/forum/viewtopic.php?f=15&t=943 Quote
Byron Posted July 1, 2012 Posted July 1, 2012 Here's a site serach I made awhile back using RecursiveDirectoryIterator and posted somewhere in this forum: http://byrondallas.heliohost.org/helio/site_search.txt Just upload it to your site and rename it with a .php extension. To search for a file it goes like this: Searching for a file named white_rose.jpg. Enter rose as the file name and any files with the name rose will show up in the results. To show all files that end in php enter .php as the file. To show ALL files in a directory, enter a . (dot). The check box that says Stop recursive means to keep it from searching in subdirectories. Quote
Vertrex Posted July 1, 2012 Author Posted July 1, 2012 wow. Thanks so much for your answers It's not exactly a project Jairy DJ. I'm just trying to get certain files out of the file system. Truth be told, I'm not very good at php or any other coding language except VB but idk how to apply VB on a website. Quote
Lugus Posted July 2, 2012 Posted July 2, 2012 wow. Thanks so much for your answers It's not exactly a project Jairy DJ. I'm just trying to get certain files out of the file system. Truth be told, I'm not very good at php or any other coding language except VB but idk how to apply VB on a website. It's not a hard task to setup a vb script, there are lots of tuts on the web and I can help you too if you encountered any trouble.Good luck! Quote
Ice IT Support Posted July 30, 2012 Posted July 30, 2012 VBscript is a client-side language that only works in Internet Explorer, thus wouldn't be much use for what you are trying to do here. To add a VBscript to your webpage, use: <script type="text/vbscript"> 'Your code here </script> Quote
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.