Since I ran this on Win2000 machine, I changed name of directory: You were right on the money with your code; just a minor mod or two was required:
<?php $i=0; // counter $files = array(); // array to store directory content // open directory $dir = opendir("c:\\wbs\\"); // loop through directory and put filenames into an array while ($filex = readdir($dir)) { $files[$i] = $filex; $i++; // pull $file (directory array into select box) $file_count .="<OPTION VALUE=\"$filex\">$filex</OPTION>\n"; } $form = "<p><FORM METHOD=\"post\" ACTION=\"blank.php3\">\n". "<SELECT NAME=\"files\">$file_count</SELECT>\n". "<INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"select\">\n". "</FORM></p>"; // close directory closedir($dir); print $form; ?> outputs the following: <p><FORM METHOD="post" ACTION="blank.php3"> <SELECT NAME="files"><OPTION VALUE=".">.</OPTION> <OPTION VALUE="..">..</OPTION> <OPTION VALUE="activities.txt">activities.txt</OPTION> <OPTION VALUE="addwbs.php3">addwbs.php3</OPTION> <OPTION VALUE="classWBS.php">classWBS.php</OPTION> <OPTION VALUE="funcs.inc">funcs.inc</OPTION> <OPTION VALUE="link.php">link.php</OPTION> <OPTION VALUE="snoopy.inc">snoopy.inc</OPTION> <OPTION VALUE="wbs.sql">wbs.sql</OPTION> <OPTION VALUE="wbsconv.php">wbsconv.php</OPTION> <OPTION VALUE="wbsform.php3">wbsform.php3</OPTION> <OPTION VALUE="wbsload.sql">wbsload.sql</OPTION> <OPTION VALUE="wbspkg.php3">wbspkg.php3</OPTION> <OPTION VALUE="wbsproject.csv">wbsproject.csv</OPTION> <OPTION VALUE="wbsproject.mpp">wbsproject.mpp</OPTION> <OPTION VALUE="xx.php">xx.php</OPTION> </SELECT> <INPUT TYPE="submit" NAME="submit" VALUE="select"> </FORM></p> -----Original Message----- From: Jas [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 9:33 AM To: [EMAIL PROTECTED] Subject: [PHP] Directory to array to select box... Ok here is my problem, for one I am new to php and would like a new pair of eyes for this piece of code, and second what I would like to accomplish is putting the contents of a directory into an array and then pulling the contents of that array into a select box for further processing... If someone could give me some more information on GetDirArray() or a different way to accomplish this problem that would be great... this is where I am thus far. <?php $i=0; // counter $files = array(); // array to store directory content // open directory $dir = opendir("/home/web/b/bignickel.net/htdocs/"); // loop through directory and put filenames into an array while ($file = readdir($dir)) { $files[$i] = $file; $i++; } // pull $file (directory array into select box) $file_count .="<OPTION VALUE=\"$file\">$file</OPTION>"; $form = "<p><FORM METHOD=\"post\" ACTION=\"blank.php3\"> <SELECT NAME=\"files\">$file_count</SELECT> <INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"select\"> </FORM></p>"; // close directory closedir($dir); ?> Then of course I just use an echo to display the select box but so far I have not been able to have it actually work so any help would be great.. Thanks in advance, jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php