I think this will be an easy question for someone with PHP experience (unlike myself)
What I've pieced together so far does this:
Gets path and filename from a specified folder and all subfolders. filters out all but text files based on extension. echos back some HTML
There are many text files in the folders that I want, but a few that I don't want. Fortunately all the ones I don't want have the same file name 'UserSelection.txt' I'm just wanting the results to return w/o those files.
Enough background here is what I have:
<?php
// folder to start search in ex: $root_dir = "files\photos";
$root_dir = "photos";
$path = dir("$root_dir");
treewalk($path);
$path->close();
function treewalk($t)
{
while($textfile=$t->read())
{
if (($textfile != '.') && ($textfile != '..'))
{
if (is_dir($t->path . "\" . $textfile))
{
$path = dir($t->path . "\" . $textfile);
treewalk($path);
$path->close();
}
if (eregi ("(.)+\.(txt$)",$textfile))
{
// removes .txt file extension from $textfile
$file = substr($textfile, 0, -4);
// returns results to browser
$folder = $t->path . "\" . $entry ."";
echo ("<hr><TABLE border=\"0\" cellpadding=\"5\" cellspacing=\"2\" width=\"100%\" >\n");
echo ("<TR><TD width=\"150\" valign=\"top\"><p><FONT size=\"2\" face=\"Arial\" >\n");
echo ("<a href=\"$folder$file.php\">\n");
echo ("<IMG src=\"$folder../thumbnails/$file.jpg\" alt=\"$file\" border=\"1\"></a><br>$file\n");
echo ("</FONT></p></TD>\n");
echo ("<TD valign=\"top\">\n");
include("$folder$file.txt");
echo ("</TD></TR></TABLE>\n\n\n");
}
}
}
}
?>
Not the most efficient code. If you have any ideas on how to clean it up feel free to post them also.
$textfile is what needs to be worked with.
I've been looking online and in the manual, but I'm not exactly sure what kind of command I'm looking for.
Any help is greatly appreciated.
Thanks!
Justin