php directory listing

accessing listed direcries

Page 1 of 1

6 Replies - 1197 Views - Last Post: 02 May 2007 - 01:27 AM Rate Topic: -----

#1 muyanga  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 18-September 06

php directory listing

Post icon  Posted 30 April 2007 - 07:35 AM

i wrote this script below with a view of listing contents of a directory, it does the listing fine but when it come to accessing the listed directories, some are accessible some refuse access. is it that i've left out something ishould include or something... Maybe i should also mention that i'm using php intergrated into my iis server together with coldfusion aswell (in case that might have something to do with it).. i'll appreciate you response thank you

here is the php script without the html part...

 <?php
						$handle=opendir(".");

						while ($file = readdir($handle)) 
						{
							if (is_dir($file) && !in_array($file,$list_ignore)) 
							  {	
							   echo '<a class="ditem" href="'.$file.'"><img src="folder.gif" alt="image dossier" border=0 /> '.$file.'</a> <BR>';
							  }
						}
						closedir($handle);
?> 


Is This A Good Question/Topic? 0
  • +

Replies To: php directory listing

#2 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 84
  • View blog
  • Posts: 3,564
  • Joined: 31-March 03

Re: php directory listing

Posted 30 April 2007 - 11:07 AM

because you're only outputting directories and not files.
Was This Post Helpful? 0
  • +
  • -

#3 Styx  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 192
  • Joined: 04-March 07

Re: php directory listing

Posted 30 April 2007 - 06:58 PM

Are you saying that you are listing all the directories in the current level as links so you can just go to them, but some are accessible and others are not? If so, how are they not?
Was This Post Helpful? 0
  • +
  • -

#4 snoj  Icon User is offline

  • Married Life
  • member icon

Reputation: 84
  • View blog
  • Posts: 3,564
  • Joined: 31-March 03

Re: php directory listing

Posted 30 April 2007 - 07:05 PM

exec("dir /B /absolute/path/for/images",$rtn)

Use ls with whatever the argument for just plain file listings on linux machines.
Was This Post Helpful? 0
  • +
  • -

#5 muyanga  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 18-September 06

Re: php directory listing

Posted 02 May 2007 - 01:12 AM

I'm sorry i couldn't come to see your replies quickly but thanx for trying to help guys...

@hotsnoj: i atfirst i didn't put that limit to bring only directories but but even then i still couldn't access then....

@Styx: i really dont know how or why this is happening... all the directories are listed. but when i try to click on them some open and display the the content(its webpaes mostly and it just opens the homepage), but others refuse access and some of those are not even system files or anything....
Was This Post Helpful? 0
  • +
  • -

#6 Styx  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 192
  • Joined: 04-March 07

Re: php directory listing

Posted 02 May 2007 - 01:27 AM

You're getting links that don't even exist?

Try this simple script:
<?php
foreach (glob('*') as $file)
{
  if (is_dir($file))
  {
	echo '<a href="' . $file . '">' . $file . '</a><br />';
  }
}
?>

Was This Post Helpful? 0
  • +
  • -

#7 muyanga  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 18-September 06

Re: php directory listing

Posted 02 May 2007 - 01:27 AM

hi again....

i figured it out.. IIS wasn't configured to give access to directory listing so that was my main problem......

thank you everyone your input somehow made me think of checking that
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1