Directory Walking

From: Date: Tue, 15 Aug 2000 20:15:23 +0000
Subject: Directory Walking
Groups: php.general 
Request: Send a blank email to php-general+get-11869@lists.php.net to get a copy of this message
Hi ya, I've been working on an automatic page generator for the intranet system in the company I work for. The system basically just allows you to toss in your name, e-mail, some other information, and some HTML It will then just use some templates and output some nicely formatted HTML with the company letterhead on it. In the current version it can only save to one directory, which is annoying. In the newer version I'm working on, I'm trying to make it walk up and down directory's, and list the directory contents in a option box. It will work fine for the home directory, and one directory above home. After that, it dies. I talked to the local PHP guy, and he was sort of stumped too... Here's some snippets of the code... <FORM ACTION="generate_test.php3" METHOD="GET"> <SELECT NAME="requested_dir" SIZE="1"> <?php if(!isset($requested_dir)) { $requested_dir = "."; } $current_directory = opendir($requested_dir); while ($entry_name = readdir($current_directory)) { if(is_dir($entry_name)) { print("<option>$entry_name</option>\n"); } } print("</SELECT>\n"); print("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n"); ?> <INPUT TYPE="SUBMIT" VALUE="Change Dir"> </form> That will generate the following HTML output <FORM ACTION="generate_test.php3" METHOD="GET"> <SELECT NAME="requested_dir" SIZE="1"> <option>.</option> <option>..</option> <option>testing</option> <option>testing.period</option> </SELECT> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <INPUT TYPE="SUBMIT" VALUE="Change Dir"> </form> In a nutshell, what I want the script to do, is know what directory it is in. If you click "..", it should go up to a higher level. I'll have to define a global variable or something, but I'm not sure. Anyone have any ideas? -- Alex Augot ex.3065 Software Process Engineering Group Teradyne, Inc Phone: 617-422-3065 Cell: 617-435-7035

« previous php.general (#11869) next »