Jump to content

Loading files from a folder and printing them out as links


battleroyalex

Recommended Posts

[code] $handle=opendir('live/');
$file = array();
while($var = readdir($handle)){
     if(is_file("live/".$var)){
          array_push($file, $file0);
     }
}[/code]

Of course replace 'live/' with your directory. All file names will be in an array called $file. You can then pass the array through a loop to print out the links.

[code]foreach($file as $k=>$v){
     echo '<a href="video.php?filename=$v">$v</a>';
}[/code]

[!--quoteo(post=362848:date=Apr 8 2006, 01:07 PM:name=battleroyalex)--][div class=\'quotetop\']QUOTE(battleroyalex @ Apr 8 2006, 01:07 PM) [snapback]362848[/snapback][/div][div class=\'quotemain\'][!--quotec--]
anybody :(
[/quote]

PS: This above example will not add '.' and '..' as filenames.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.