nvfd412 Posted January 4, 2007 Share Posted January 4, 2007 I'm attempting to create a web form that will search a share with multiple sub dir's and open the filename that was submitted in the form, is that possible with out having to hard code all the sub dir's as an array?Sample of code that will open a file in a single share (\\server\sharedir), but I'm unable to parse the sub dir's to find the same file. Any idea and help is appreciated.Code:<?php//***** \\\shareDrive\\shareDir$path ='\\\sharedrive\\sharedir\\';#################################// initialize counter$count = 0;// set directory name//$dir = "$path"//open directory and parse file listif ($handle = opendir($path)) { while (false !== ($file = readdir($handle))) {// iterate over file list// print filenameswhile (($filename = readdir($handle)) !== false){if (($filename != ".") && ($filename != "..")){$count ++;//echo $path . "/" . $filename . "\n";}}}}//echo "-- $count FILES FOUND --"; ###################################// set file to read$filename = 'filename';//echo "($path$filename)";// open file$fh = fopen ("$path$filename", "r") or die("Could not open file");//echo $fh;// read filewhile (!feof($fh)){$data = fgets($fh);echo $data;}// close filefclose ($fh);// close directoryclosedir($handle);//echo "-- ALL DONE --";?> Link to comment https://forums.phpfreaks.com/topic/32887-help-scanning-sub-dir-and-open-files-newbie/ Share on other sites More sharing options...
curtis_b Posted January 5, 2007 Share Posted January 5, 2007 I had to do this too, create a script that could search an ever-changing fileserver on our network. I used ajax - you can see a demo of the app here: [font=Verdana]http://www.curtisbranum.com/portfolio/ajax.swf[/font]anyway, I don't have the code with me, but I'll try to remember to post it when I'm at work tomorrow. To speed things up, I have one script that builds a db table of all current file/folder names, so the php script is really just looking through the database table. Link to comment https://forums.phpfreaks.com/topic/32887-help-scanning-sub-dir-and-open-files-newbie/#findComment-153197 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.