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"> Quote Link to comment 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 Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
marklarah Posted June 15, 2008 Share Posted June 15, 2008 But hes a b00n! Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.