Jump to content

please help me out from simple php example.


raj123

Recommended Posts

Hi all,

 

I need to show output as list of files and folders in directory and should be able to access the files in the folders(using files and folders as links). I am able to show the out with files and folders but not able to change the files and folders to links. I need to use forms for this. I dont have any idea about. please if any one understands my problem try to help me out.

I'm not quite sure exactly what you're asking. It sounds like you want a list of all the files and folders in a directory as a link.

 

<?php
function dirList ($directory) {
$results = array();
$handler = opendir($directory);
while ($file = readdir($handler)) {
	if ($file != '.' && $file != '..') {
		$results[] = $file;
	}
}
closedir($handler);
return $results;
}
$dir = "./path/to/files/";
$files = dirList($dir);
foreach ($files as $file) {
echo "<a href=\"$file\" title=\"$file\">$file</a><br />";
}
?>

hey charlie

 

Thanks a lot for your response. you got my point, but the problem is when i click the folder 'A' i am not able view the files of that folder 'A'. Instead I am geting the following

 

Not Found

 

The requested URL /phpmywork/examples/old hws was not found on this server.

Apache/2.0.63 (Win32) PHP/5.2.5 Server at localhost Port 80

 

 

Thank you,

 

raj

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.