SecureMind Posted October 27, 2009 Share Posted October 27, 2009 Here's the problem, 1. I have an application that dumps a specific type of log file to a drive on the server it runs on. 2. The file is named with a name based on a number of factors such as IP addresses and so on. 3. I'm running a number of scripts and pages based on parsing that local file. I would like to have a form that will allow me to browse and select one of these local to the webserver files. (not to be confused with the ability to browse files local to the end user) Any suggestions. Thanks, Josh Link to comment https://forums.phpfreaks.com/topic/179202-can-i-create-a-form-to-browseselect-a-file-local-to-the-web-server/ Share on other sites More sharing options...
cags Posted October 27, 2009 Share Posted October 27, 2009 You should certainly be able to iterate through the files and create a list that could be output in some way allowing the user to choose (anchor links, dropdown box etc. But if your asking if theres a handy 'Open File' type dialog then I fear the answer is no. Link to comment https://forums.phpfreaks.com/topic/179202-can-i-create-a-form-to-browseselect-a-file-local-to-the-web-server/#findComment-945541 Share on other sites More sharing options...
SecureMind Posted October 27, 2009 Author Share Posted October 27, 2009 Ok so I tried this to start with. This looks at all the files in the directory and creats a listing <?php /* This is for creating an uploadeded file list */ $source = opendir("upload/"); $HTML = ""; $alt = "stripped file"; $count = 0; if($source){ while(($file = readdir($source)) !== false){ if(!is_dir($file)){ $HTML = $HTML ."<a href=\"upload/$file\" >$file</a>\n"; $count++; } if($count == { $HTML = $HTML . "<br />"; $count = 0; } } } else{ echo "could not open directory"; } echo $HTML; ?> Then I call it within a web page with this: <?php include('sample.php'); ?> The next question is, lets say I do indeed want to have this as a drop down selection menu... what my next step? Link to comment https://forums.phpfreaks.com/topic/179202-can-i-create-a-form-to-browseselect-a-file-local-to-the-web-server/#findComment-945551 Share on other sites More sharing options...
cags Posted October 27, 2009 Share Posted October 27, 2009 If you wish to use a dropdown selection then rather than append an anchor link you would be using $HTML = '<selection name="file">'; // then in the loop $HTML .= '<option>' . $file . '</option>'; // then after the loop $HTML = '</selection>'; You'd probably also add form tags at the top and bottom and a Submit button, it all depends on the overall layout of your code etc and what you need. Link to comment https://forums.phpfreaks.com/topic/179202-can-i-create-a-form-to-browseselect-a-file-local-to-the-web-server/#findComment-945556 Share on other sites More sharing options...
SecureMind Posted October 27, 2009 Author Share Posted October 27, 2009 ok so I think I've got this, I: <?php /* This is for creating an uploadeded file list */ $source = opendir("upload/"); $HTML = ""; $alt = "stripped file"; $count = 0; $HTML = '<selection name="file">'; if($source){ while(($file = readdir($source)) !== false){ if(!is_dir($file)){ $HTML .= '<option>' . $file . '</option>'; $count++; } if($count == { $HTML = $HTML . "<br />"; $HTML = '</selection>'; $count = 0; } } } else{ echo "could not open directory"; } echo $HTML; ?> So now I still get just a text file output with: <?php include('sample.php'); ?> now I assume I need to take that and somehow move the $HTML into a dropdown box? Link to comment https://forums.phpfreaks.com/topic/179202-can-i-create-a-form-to-browseselect-a-file-local-to-the-web-server/#findComment-945565 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.