Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PHP echo contents of folder help
#1
Ok i have a folder i use to upload images among other things.
Now i want a script to allow me and a select few others to view the contents and click on the file name to load the image or whatever.
I have that working largely however i cant seem to get it to link to the file.
Now im not going to post the vb hooks as there is no need however the below is the code i am using to sort the folder and display its contents.
Its doing that ok. Displaying based on time stamp however i cant get the linking to work properly. I get the link with an array at the end.
Here is the code for anyone that can help.
Also if you see other issues please let me know.
Me and coding dont go well together.
Im more of a porn man Pirate

PHP Code:
<?php
   $path 
$_SERVER[DOCUMENT_ROOT]."XXXXXXXXXXXX";
   
$dh = @opendir($path);

   while (
false !== ($file=readdir($dh)))
   {
      if (
substr($file,0,1)!=".")
         
$files[]=array(filemtime($path.$file),$file);   
   }
   
closedir($dh);

   if (
$files)
   {
      
rsort($files); #sorts by filemtime

      
foreach ($files as $file)
         echo
"<a href=http://www.MY URL HERE/$file>$file[1]</a><br>\n";  #file[0]=Unix timestamp; file[1]=filename
   
}
?>

Thanks if anyone can help.

Fixed it. I was calling up the timestamp instead of the file for the link reference lol.
Man im useless at this.
The Rules!
FTW Forum <-- Home of the Damned! --> Join me On MM


Reply
#2
Glad you found your area of mistake.
Next time I'd say go to HF, they have more people to help you trust me.
I hate seeing threads blank when it's supposed to be SupportForums.
Reply
#3
You are calling the file from the url. Unless your files are in your root web directory, it won't work. Make sure you append the document root to the url link.
Reply
#4
This has been resolved a long time ago but thanks for the replies.
The Rules!
FTW Forum <-- Home of the Damned! --> Join me On MM


Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PHP Framework List: An Ultimate Guide to 102 PHP Frameworks for Web Developers tk-hassan 0 941 07-27-2020, 11:26 PM
Last Post: tk-hassan
  [NEED HELP] PHP Form post, get, echo Đενɨаηсε™ 5 2,077 02-06-2012, 01:16 PM
Last Post: ★Cooldude★
  PHP Video Tutorials (PHP For Beginners) Eleqtriq 4 3,667 10-10-2011, 01:00 PM
Last Post: Greyersting
  PHP Echo HTML From MySQL Value? iMr 7 3,771 03-19-2011, 09:41 AM
Last Post: ★Cooldude★
  How can I echo a variable `P R O D I G Y™ 9 2,786 12-09-2010, 09:05 AM
Last Post: Orgy

Forum Jump:


Users browsing this thread: 1 Guest(s)