Page 1 of 1

Making links to files in a directory

Posted: Fri Apr 04, 2008 2:02 pm
by phpdesigner
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


Iam using the programme php expert editor and it have an internal http server I wanted to make a link for evey file in a directory and I wrote the following code

Code: Select all

 
<?php
$alaa=opendir("d:/lectures/");
while($alaa1=readdir($alaa))
{
  if($alaa1!="." && $alaa1!="..")
  {
 echo "<a href=d:/lectures/$alaa1> $alaa1 </a><br>";
  }
}
?>
 
when I tested this code on php expert editor it worked but a rare files espicially chm files didnot open and also folders didnot open .
Secondly when i tried this code on firefox it always send me an alert box telling me that it doesnot know how to open the adresses of the files because the protocol(d) isnot associated with any programme so I want to understand this and also it didnot work on the internet explorer
Note : when I open the directory of my wamp server I could open all files and folders in it I know that this is complicated but please can any one answer me. :?: :!:


~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.

Re: Making links to files in a directory

Posted: Fri Apr 04, 2008 4:59 pm
by pickle
You need to put your file path in quotes for proper html form - that might be messing the link up too when a filename has a space in it.

The way your path is currently set up, "d" is in the place "http","https", or even "ftp" is in a usual url. I'm not sure exactly what the syntax is, but you need to preface it with a protocol that describes the URL as a local path. I'd guess "file://d:/..."

Re: Making links to files in a directory

Posted: Sun Apr 06, 2008 3:47 pm
by phpdesigner
Thank you so much but please Iam sorry because I asked quickly in the first reply but I deleted it and my question is how can I describe the url as a local path :oops: