PHP code to List folder contents as HTML hyperlinks
Posted: Sun Dec 06, 2009 9:17 am
Hi,
I have my PHP 5 running in IIS 6.0. I have my application hosted on IIS. I need to list all the contents of a specific folder in the server as as hyperlinks in my HTML. I was trying to use the PHP code. But, it does not work when I embed in the HTML.
Is there a better way to embed PHP in HTMLs?
Please help me with the php code that serves this purpose.
$dir = opendir('files/');
echo '<ul>';
while ($read = readdir($dir)) {
if ($read!='.' && $read!='..') {
echo '<li><a href="files/'.$read.'">'.$read.'</a></li>';
}
}
echo '</ul>';
closedir($dir);
_____ERROR_____________
.$read.''; } } echo '
'; closedir($dir); ?>
_________________________
Thanks.
Subs
I have my PHP 5 running in IIS 6.0. I have my application hosted on IIS. I need to list all the contents of a specific folder in the server as as hyperlinks in my HTML. I was trying to use the PHP code. But, it does not work when I embed in the HTML.
Is there a better way to embed PHP in HTMLs?
Please help me with the php code that serves this purpose.
$dir = opendir('files/');
echo '<ul>';
while ($read = readdir($dir)) {
if ($read!='.' && $read!='..') {
echo '<li><a href="files/'.$read.'">'.$read.'</a></li>';
}
}
echo '</ul>';
closedir($dir);
_____ERROR_____________
.$read.''; } } echo '
'; closedir($dir); ?>
_________________________
Thanks.
Subs