PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
ogelami
Forum Newbie
Posts: 1 Joined: Tue Mar 18, 2008 1:32 pm
Post
by ogelami » Tue Mar 18, 2008 1:37 pm
i think im stuck here, i need a solution for my project.
i want a possibility to view the files without downloading them by clicking them, and ability to view folders.
Code: Select all
<?php
$dir = new DirectoryIterator( '.' );
foreach($dir as $file ){
if(!$file->isDot() && !$file->isDir()); {
echo "FileName: <a href='".$file->getFilename();
echo "'>" .$file->getFilename();
echo "</a>";
echo "<BR/>";
echo "Size: ".number_format(($file->getSize()/1024),2)." Kb";
echo "<BR/>";
echo "Date Created: ".date("D d M Y H:i:sa",$file->getCTime());
echo "<BR/>";
echo "<BR/>";
}
}
echo "<a href='index.php'>Back.</a>"
?>
any one got a solution?
scriptah
Forum Commoner
Posts: 27 Joined: Sat Mar 15, 2008 8:58 pm
Location: Long Island, NY
Post
by scriptah » Tue Mar 18, 2008 2:16 pm
About displaying directories ...
Code: Select all
if(!$file->isDot() && !$file->isDir()); {
You should remove the second condition.
I didn't understand what you meant by "viewing the file without downloading them".
Which types of file are you going to display?
pickle
Briney Mod
Posts: 6445 Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:
Post
by pickle » Tue Mar 18, 2008 3:01 pm
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.