Jump to content

Recommended Posts

Posted

Hi all hope you can help

 

I'm wanting to read content from a folder and display this on a webpage. Thus when we have letters home ect parents are able to download them !! and dont need to keep updating the website.

 

I use to do this on my old school webpage but for the life of me could'nt work out how i done it.

 

Any ideas

 

Thank You !!

  • 2 weeks later...
Posted

If you've got PHP available on your web server, just bung this into an index.php file:

 

				 	$path = "./";
	 	$dir_handle = @opendir($path) or die("Unable to open $path");
	  	while (false !== ($file = readdir($dir_handle))) {
		if($file == "index.php")
   		continue;
		echo "$file
"; }
		closedir($dir_handle);
		?>

 

Will list everything in that directory (except the index.php file) and create a link to it :)

  • Thanks 1
Posted
This Worked a treat. Stick it with a style sheet bobs your uncle !!

 

THANKS A BUNCH !! he he ! (one happy man)

 

Hehe, glad I could be of assistance!

  • 6 months later...
Posted

Been having another play and now i would like to read a different folder where the php page does'nt sit.

 

I can get them to list contence of another folder but i can seem to get the folder name into the url so the file will open. Elp

 

<?php

$path = "./graphics";

$dir_handle = @opendir($path) or die("Unable to open $path");

while (false !== ($file = readdir($dir_handle))) {

if($file == "index.php")

continue;

echo "$file

"; }

closedir($dir_handle);

?>

 

 

Many Thanks

Posted

I would think the following should do it:

 

echo "$file
"; }

 

The readdir will dump out to names within that directory, but won't put the path in.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...