ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-general
php-general
[PHP] Re: Directory to array to select box...
by Michael Virnstein other posts by this author
Apr 5 2002 4:43PM messages near this date
[PHP] Directory to array to select box... | [PHP] Re: Directory to array to select box...
ok, i'll try to help, but first use "while (false !== ($file =
readdir($dir))". ;)
why do you need hidden fields on that page? to determine which file
the user has selected? hmmm...ok, let's see:
The user sees your form, selects the desired file and submits the form.
Now the page processing the request will know which one was selected.
in your case $files will contain the value of the selected option field
within
the select-box files. So why do you need additional input fields for that?
Please explain a bit more detailed what exactly is your problem.

"Jas" <jlgerfen@[...].com>  schrieb im Newsbeitrag
news:20020405160407.80092.qmail@[...]..
>  Ok I tried a different way to do it and this is the resulting code... I
>  still need to be able to make some hidden fields so the contents of the
item
>  selected may be passed to another script which will stick the path of the
>  file into a database table if anyone wants to give me a hand with that
part.
>  Here is what I have and it is working as far as just reading the directory
>  and putting the contents into a select box...
>  <?php
>  // varible to hold path to directory we wish to open
>  $dir_name = "/path/to/directory/on/server/";
>  // opening directory
>  $dir = opendir($dir_name);
>  // varible to start form
>  $file_list .= "<p><FORM METHOD=\"post\" ACTION=\"db.php3\">
>  <SELECT NAME=\"files\">$file_name";
>  // read the directory and place them into file names for further
processing
>  while ($file_name = readdir($dir)) {
>  // exclude "." and ".." file names
>   if (($file_name != ".") && ($file_name !="..")) {
>  // variable to place results of directory into select box
>   $file_list .= "<OPTION VALUE=\"$file_name\">$file_name</OPTION>";
>    }
>   }
>  // closing select and form and adding select button
>   $file_list .= "</SELECT><br><br><INPUT TYPE=\"submit\" NAME=\"submit\"
>  VALUE=\"select\"></FORM></p>";
>  // close the directory
>  closedir($dir);
>  ?>
>  If anyone knows how to do this in a better way please let me know, but
this
>  works and all it needs is some hidden fields (i am assuming here) so that
>  the item that the user selects from the list can be further processed,
like
>  sticking the file path (not the actual file) into a database table.  (I
need
>  help with that...)  Enj0y!
>  Jas
> 
> 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Thread:
Jas
Michael Virnstein
Michael Virnstein
Jas

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved