It is currently Tue Mar 19, 2019 6:29 am


All times are UTC


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: PHP: Show Files in Folder
PostPosted: Tue Oct 09, 2007 2:42 pm 
Getting Started
Getting Started

Joined: Sun Apr 09, 2006 4:04 pm
Posts: 63
Location: Canada
How can I set up a file that when loaded, it will pass the names and link to to a variable, so I can send that to the end page? (Ok that makes no sense...)

Code:
Example:
File Location: /gallery/
4 files, all png

Without manually adding them in, how can I show those files? Using PHP?

_________________
Image
Shadow Generator


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 09, 2007 4:43 pm 
Moderator
Moderator

Joined: Tue Feb 27, 2007 12:18 am
Posts: 521
i just ripped this off one of my websites (and took some bits out)

Code:

<?php
$d = "gallery";

$dir = getcwd() . "/" . $d . "/";   

if (is_dir($dir)) {
   if ($dh = opendir($dir)) {
      while (($file = readdir($dh)) !== false) {
         if ((filetype($dir . $file) <> "dir")AND($file <> ".")AND($file <> "..")){
            echo "<a href='$d/$file'>$file</a>";
         }
         }
   }
}

?>


_________________
http://www.mjmclocks.co.uk


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ]  Moderators: Moderators, Support Team

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Hosting | Domains | Servers | Extras | Order | Support | Contacts | FreeHostia © 2011