Wideawake Posted June 15, 2008 Share Posted June 15, 2008 So Im working on making a very simple php script to pull filenames from a directory and post the link as the same of the file. I a b00n when it comes to php and Im trying to learn. So far I got this piecing together some stuff. If anyone could help make it all in one drop down and remove the . and .. boxes it would be great! Thanks for any help in advanced, Mike <?php $dir="/my/file/downloads"; // Directory where files are stored if ($dir_list = opendir($dir)) { while(($filename = readdir($dir_list)) !== false) { echo '<SELECT name=ID>'; echo '<OPTION value='.$filename.'> '.$filename.''; echo '</select>'; ?> <?php } closedir($dir_list); } ?> <input type="submit" value="Download" name="Download"> Link to comment https://forums.phpfreaks.com/topic/110274-drop-down-menu-and-php/ Share on other sites More sharing options...
ratcateme Posted June 15, 2008 Share Posted June 15, 2008 <?php $dir="/my/file/downloads"; // Directory where files are stored if ($dir_list = opendir($dir)) { echo '<SELECT name=ID>'; while(($filename = readdir($dir_list)) !== false) { if($filename != '..' && $filename != '.'){ echo '<OPTION value='.$filename.'> '.$filename.'</option>'; } } echo '</select>'; closedir($dir_list); } ?> <input type="submit" value="Download" name="Download"> that should work better Link to comment https://forums.phpfreaks.com/topic/110274-drop-down-menu-and-php/#findComment-565822 Share on other sites More sharing options...
Wideawake Posted June 15, 2008 Author Share Posted June 15, 2008 Very nice! Thanks so much for your help! You wouldn't happen to know if theres a way to put txt in the first then drop down and see files? Like when you get to the page it says Choose File to Download, then drop down with all the files in it? Again I do appreciate your time helping the b00n. ~Mike Link to comment https://forums.phpfreaks.com/topic/110274-drop-down-menu-and-php/#findComment-565824 Share on other sites More sharing options...
trq Posted June 15, 2008 Share Posted June 15, 2008 Of course there are ways of doing these things. Were not here to pump out code for you though, how about your start by trying to write something and post your code when you run into trouble. Link to comment https://forums.phpfreaks.com/topic/110274-drop-down-menu-and-php/#findComment-565827 Share on other sites More sharing options...
marklarah Posted June 15, 2008 Share Posted June 15, 2008 But hes a b00n! Link to comment https://forums.phpfreaks.com/topic/110274-drop-down-menu-and-php/#findComment-565835 Share on other sites More sharing options...
Wideawake Posted June 15, 2008 Author Share Posted June 15, 2008 Of course there are ways of doing these things. Were not here to pump out code for you though, how about your start by trying to write something and post your code when you run into trouble. Thats what I did at first but I know this has got to be a one liner.....lol at least I admit Im a b00n and I have searched, so its not like Im not trying. Link to comment https://forums.phpfreaks.com/topic/110274-drop-down-menu-and-php/#findComment-566098 Share on other sites More sharing options...
trq Posted June 15, 2008 Share Posted June 15, 2008 so its not like Im not trying Then post your code and a description of your issue. Link to comment https://forums.phpfreaks.com/topic/110274-drop-down-menu-and-php/#findComment-566099 Share on other sites More sharing options...
marklarah Posted June 15, 2008 Share Posted June 15, 2008 You do relieze that "b00n" isn't real? Its a typo I presume. Link to comment https://forums.phpfreaks.com/topic/110274-drop-down-menu-and-php/#findComment-566125 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.