Current location: Hot Scripts Forums » Programming Languages » PHP » OpenDir


OpenDir

Reply
  #1 (permalink)  
Old 01-16-09, 09:53 PM
xEX3CUT1ONx xEX3CUT1ONx is offline
Wannabe Coder
 
Join Date: Jun 2008
Posts: 122
Thanks: 2
Thanked 0 Times in 0 Posts
OpenDir

Hello, I have recently made an upload script, and then i was messing around with opendir to display the files within the folder..

PHP Code:



<?php

$dir 
opendir("upload");

//List files in images directory
while (($file readdir($dir)) !== false)
  {
  echo 
"filename: " $file "<br />";
  }
  
closedir($dir);
?>
Then on the upload page i want a table with the Directory been shown, however I would like the links to be clickable as a download. I was wondering about how to go about it.

Thanks. . .
Reply With Quote
  #2 (permalink)  
Old 01-17-09, 02:15 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
PHP Code:

<?php

$dir 
opendir("upload");

?>
<table>
<?php
//List files in images directory
while (($file readdir($dir)) !== false)
{
    
?>
    <tr>
        <td><a href="upload/<?php echo $file?>"><?php echo $file?></a></td>
    </tr>
    <?php
}

closedir($dir);

?>
</table>
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting opendir function lindasnephew PHP 2 05-26-08 03:54 PM
Help with opendir connor PHP 0 12-20-05 09:56 AM
Problem with handle on opendir !!BUBBLES!! PHP 4 09-25-03 07:48 AM


All times are GMT -5. The time now is 08:26 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.