Help on Directory Listing
Posted: Fri Jul 30, 2010 2:13 am
Hi guys,
I am currently trying to work out a directory drop down list on my website and I want it when the user select from the drop down list, it will POST it to the next page. I am able to get it working on google chrome but not on IE and Fire Fox and have been stuck for a while. The code are as follows:
send.php:
<form action="receive.php" method="post">
<select name="aaa">
<?php
echo "<select name=\"file\">\n";
foreach (new DirectoryIterator('.') as $file) {
// if the file is not this file, and does not start with a '.' or '..',
// then store it for later display
if ( (!$file->isDot()) && ($file->getFilename() != basename($_SERVER['PHP_SELF'])) ) {
echo "<option>";
// if the element is a directory add to the file name "(Dir)"
echo ($file->isDir()) ? "(Dir) ".$file->getFilename() : $file->getFilename(); //////
echo "</option>\n";
}
}
echo "</select>\n";
?>
</select>
<input type="submit" />
</form>
receive.php:
<?php
$name = $_POST['aaa'];
echo $name
?>
I really hope that someone could help me out here. I am sorry and thank you for the trouble as I am still new to PHP and learning on the go here.
Regards
Jes
I am currently trying to work out a directory drop down list on my website and I want it when the user select from the drop down list, it will POST it to the next page. I am able to get it working on google chrome but not on IE and Fire Fox and have been stuck for a while. The code are as follows:
send.php:
<form action="receive.php" method="post">
<select name="aaa">
<?php
echo "<select name=\"file\">\n";
foreach (new DirectoryIterator('.') as $file) {
// if the file is not this file, and does not start with a '.' or '..',
// then store it for later display
if ( (!$file->isDot()) && ($file->getFilename() != basename($_SERVER['PHP_SELF'])) ) {
echo "<option>";
// if the element is a directory add to the file name "(Dir)"
echo ($file->isDir()) ? "(Dir) ".$file->getFilename() : $file->getFilename(); //////
echo "</option>\n";
}
}
echo "</select>\n";
?>
</select>
<input type="submit" />
</form>
receive.php:
<?php
$name = $_POST['aaa'];
echo $name
?>
I really hope that someone could help me out here. I am sorry and thank you for the trouble as I am still new to PHP and learning on the go here.
Regards
Jes