Jump to content

Archived

This topic is now archived and is closed to further replies.

battleroyalex

Loading files from a folder and printing them out as links

Recommended Posts

Can someone help me with a php code that loads files from a folder and then prints out a url like this

[code]www.mydomain.com/video?name="filenamehere"[/code]

I don't even know where to start please point me in a direction, thanks guys

Share this post


Link to post
Share on other sites
Have a look at php.net/dir

It has all the commands and examples you could need

Stephen

Share this post


Link to post
Share on other sites
[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.

Share this post


Link to post
Share on other sites

×

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.