Need help with PHP Directory Listing
3 posts
• Page 1 of 1
Need help with PHP Directory Listing
I have a problem with listing directory on my ftp.
I have a folder called downloads on the ftp server where i have some music videos... the file that reads that directory is outside that folder.
When i put the file back into the downloads folder it reads the direcotry fine and when i include it as php it wont read... well it reads the main dir not the downloads.
So i changed default_dir to "downloads" and i placed the php files into the main root. Now when i include it... it reads the downloads dir but with errors... it wont read the size and date >_<
here's the code i used:
- Code: Select all
<TABLE BORDER="0" WIDTH="100%" CELLSPACING="3" CELLPADDING="0">
<TR>
<TD height="16" valign="middle" bgcolor="#4E5857"><font color="#FFFFFF" size="1" face="Verdana"><b>File Name</b></font></td>
<TD valign="middle" bgcolor="#4E5857"><font color="#FFFFFF" size="1" face="Verdana"><b>Size</b></font></td>
<TD valign="middle" bgcolor="#4E5857"><font color="#FFFFFF" size="1" face="Verdana"><b>Date</b></font></td>
</TR>
<style>
.style5 {font-family: Verdana; font-size: 10px; text-decoration: none; color: #FFFF00; }
</style>
<?php
$default_dir = "downloads";
if(!($dp = opendir($default_dir))) die("Cannot open $default_dir.");
while($file = readdir($dp)) $filenames[] = $file;
sort($filenames);
for($i=0; $i < count($filenames); $i++)
if($filenames[$i] != '.' && $filenames[$i] != '..' && $filenames[$i] != '.htaccess' && $filenames[$i] != 'videolist.php' && $filenames[$i] != 'main.css' && $filenames[$i] != 'index.php')
echo "<TR><TD><FONT FACE=\"Verdana\" SIZE=\"1\"> ".$filenames[$i]."</TD>" . "<TD><FONT FACE=Verdana SIZE=1>" . number_format(filesize($filenames[$i])/1000000) . "MB" . "</TD>" .
"<TD><FONT FACE=Verdana SIZE=1>" . date_str(filectime($filenames[$i])) . "</TD></TR>\n";
closedir($dp);
function date_str($timestamp) {
$date_str = getdate($timestamp);
$year = $date_str["year"];
$mon = $date_str["mon"];
$mday = $date_str["mday"];
$hours = $date_str["hours"];
$minutes = $date_str["minutes"];
$seconds = $date_str["seconds"];
return "$mday/$mon/$year";
}
?>
</TABLE>
and the page is here http://www.keitex.co.uk/index.php?view=videos
- [Dima]
Hi Sketch, I would hang around a little while for Weaver to see this, he is the programming guru around here
"Life is merely a fraction of a second. An infinitely small amount of time to fulfill our desires, our dreams, our passions." Paul Gauguin (1848 - 1904)
AEST
AEST
- Dalsim
- PROfessional Member
- Posts: 1119
- Joined: Sun Jun 15, 2003 7:07 am
- Location: Queensland, Australia
3 posts
• Page 1 of 1
Return to HTML, CSS, and Scripts
Who is online
Users browsing this forum: No registered users and 2 guests