Jump to content

opendir function (problem with folder hierarchy)


Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

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