Page 1 of 1
Reading files in a directory?
Posted: Fri Dec 19, 2003 12:29 am
by William
Code: Select all
<?php
$dirname = "/home/william/public_html/enews/templates";
$dh = opendir( $dirname ) or die("");
while ( $file = readdir( $dh ) ) {
print "<option value="templates/$file/template.htm">$file</option>";
}
Closedir( $dh );
?>
Is my coding ity acces lots it will allow people tyo upload themes and it will auto be able to be used .ect but when it reads the templates folder.... it puts ., .., ..., .ect and then files... Is there anyway i can make that go away? thanks.
Posted: Fri Dec 19, 2003 2:07 am
by Nay
Use is_file() to check if it a file, if it is, echo the option, else do nothing.
-Nay
Posted: Fri Dec 19, 2003 9:55 pm
by William
lol, I want it to show a list of files not check if its a file... Im making somthing that is going to make a list of html options into a form buy getting ithe info and directory information in a folder so all you do is upload a theme intoa folder and you can install it with out having to go into script jsut upload and go...