raj123 Posted March 10, 2008 Share Posted March 10, 2008 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. Quote Link to comment Share on other sites More sharing options...
soycharliente Posted March 10, 2008 Share Posted March 10, 2008 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 />"; } ?> Quote Link to comment Share on other sites More sharing options...
raj123 Posted March 10, 2008 Author Share Posted March 10, 2008 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 Quote Link to comment Share on other sites More sharing options...
Nuv Posted March 10, 2008 Share Posted March 10, 2008 Have you checked the path you have entered is correct or not acc. to which it is mentioned Quote Link to comment Share on other sites More sharing options...
raj123 Posted March 10, 2008 Author Share Posted March 10, 2008 I have changed the path too..........I can see the list of files and folders, but not able open the folders or files. If not files at least i should open folders. please say me requried changes. Quote Link to comment Share on other sites More sharing options...
soycharliente Posted March 10, 2008 Share Posted March 10, 2008 Pass in the folder (maybe a $_POST) and recall the function. Quote Link to comment Share on other sites More sharing options...
raj123 Posted March 10, 2008 Author Share Posted March 10, 2008 hey... I am new to PHP....I dont know how to use the $_get/$_post. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.