Re: Populate picklist from directory and return file name



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";
?>

.



Relevant Pages

  • Re: Why php and not C?
    ... > Leaping from php to C is one thing, leaping from C to assy is another. ... With todays IDEs running a test on a php script vs ... You can have an html page and embed php in it, where as with perl / c you ... it is very simple to convert an html site into a dynamic php site, ...
    (comp.lang.php)
  • POST in Apache server
    ... I'm new in the php world and I have a problem. ... ipt from a web page hosted on an Apache server. ... I use in the html to invoke the php script: ...
    (php.general)
  • Re: Large File Not Being Sent To Client
    ... I tried changing the php script to do fopen, fread, echo, ... The messages in the log file stop at 10MB, ... Without the header the browser is free to figure on it's own how long the data should be. ...
    (comp.lang.php)
  • Re: load in a php page from javascript
    ... In a html page, I don't know how to load in a php page from javascript. ... The executed content from the php script is supposed loaded into the treemenu div. ...
    (comp.lang.javascript)
  • "Cannot modify header information" with large HTML FORM options
    ... I'm having some really odd behavior with a PHP script. ... the for loop to 94 iterations, ... Looking at the raw HTML, there doesn't appear to be any significant ...
    (comp.lang.php)