Re: Populate picklist from directory and return file name
- From: "Mike Gatny" <gatny@xxxxxxxxxxxxxxxxxxxxx>
- Date: 14 Sep 2005 20:07:53 -0700
Create a new PHP script like this:
<html>
<body>
<h3>Select a log file:</h3>
<form method="get" action="YOUR_EXISTING_SCRIPT.PHP">
<select name="log_file">
<?php
/* Use of glob() requires PHP 4.3.0 or higher.
* See http://us2.php.net/manual/en/function.glob.php */
$log_dir = "/var/log/";
$pattern = "*.log";
foreach (glob($log_dir . $pattern) as $fname) {
echo " <option value=\"$fname\">$fname</option>\n";
}
?>
</select><input type="submit" value=" OK ">
</form>
</body>
</html>
Then, in your existing script, access the log file name like this:
<?php
$fname = $_GET['log_file'];
echo "You selected the log file $fname\n";
?>
.
- References:
- Prev by Date: Re: another php question
- Next by Date: Re: PHP will not allow me to create new files that are unlocked?!
- Previous by thread: Populate picklist from directory and return file name
- Next by thread: another php question
- Index(es):
Relevant Pages
|