Jump to content

Need some help with a PHP file-browsing script


tokmaz

Recommended Posts

Hi, im currently making a Intranet for local company, but i'm having some trouble with a PHP file browsing script. The security of the script is non important, because this is only to be used locally by the company.

 

The script will link to files and folders on the server, so that you can browse though them and open them.

 

This is my code for the script:

				$rotdir = "intranett"; //Hvor skal den lete etter filer?
				if (isset($_GET['undermappe'])){
				$sub = $_GET['undermappe'];
				$dirname = "$rotdir/$sub/";
				}
				else {
				$dirname = "$rotdir/";
				}
				$dirhandle = opendir($dirname); //Åpne mappen
				while($file = readdir($dirhandle)) //Loop gennom mappen
				{
				    if ($file != "." && $file != "..") //Fjern . og ..
				    {
				        if (is_file($dirname.$file)) //Sjekk om det er en fil eller en mappe
				        {
				            echo "<img src='images/fil_ikon.png' /> <a href='" . $dirname.$file . "'>" . $file . "</a><br />";
				        }
				        else
				        {
				            echo "<img src='images/mappe_ikon.png' /> <a href='" . $_SERVER['PHP_SELF'] . "?undermappe=" . $file . "'>" . $file . "</a><br />";
				        }
				    }
				}
				?> 

 

You can view the temp site here:

http://staerk.eksponett.no

 

My problem is to make the script work in more than one sub directory. I'm not very skilled in PHP, so can't figure out how. I really appriciate any help :)

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.