Jump to content

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  :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.