thedevilinthedetails Posted April 7, 2008 Share Posted April 7, 2008 I recently started some cgi programming with php. On my WAMP server I have a folder called php_cgi, which only contains index.php, and inside of it a folder titled cgi-bin where all of the cgi files are stored. Index.php looks like this <?php if ($handle = opendir('cgi-bin')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $direc = "cgi-bin"; $link = ${"cgi-bin/" .$file}; echo "<a href='$link'>$file</a><br>"; } } closedir($handle); } ?> Currently I get an output of <body> <p> <a href=''>helloworld.cgi</a><br></p> </body> I use a similar php script for my other folders but in those all of the files are stored in one folder. Any help getting this script to actually enter the correct file location in the <a href output would be great. Thank you in advance ~Dafydd Link to comment https://forums.phpfreaks.com/topic/99930-opendir-function-problem-with-folder-hierarchy/ Share on other sites More sharing options...
rhodesa Posted April 7, 2008 Share Posted April 7, 2008 Remove the ${} from this line: $link = ${"cgi-bin/" .$file}; so it should look like: $link = "cgi-bin/" .$file; Link to comment https://forums.phpfreaks.com/topic/99930-opendir-function-problem-with-folder-hierarchy/#findComment-511128 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.