Jump to content

All files into List/Menu with submit button help?


maxrpg123

Recommended Posts

hello

 

I have this code which works perfectly for what i want and what it does is gets every file in a folder and lists them all into a List/Menu box on the page.

 

<?php echo "<select name='yourfiles'>";
//The path to the style directory
$dirpath = "New Folder/";
$dh = opendir($dirpath);
while (false !== ($file = readdir($dh))) {
//Don't list subdirectories
if (!is_dir("$dirpath/$file")) {
//Truncate the file extension and capitalize the first letter
echo "<option value='$file'>" . htmlspecialchars(ucfirst(preg_replace('/\.txt*$/', '', $file))) . '</option>';
}
}
closedir($dh); 
//Close Select

echo "</select>";
?>

 

What i cant figure out is how do i add a submit button to it and display the selected file name on the next page?  :confused:

 

 

What im aiming to do is select a file from the list menu and when i click submit it will open the selected file and show its contents (text) on the webpage.

 

any help would be greatly appreciated thank you  :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.