imroue wrote:mydir is now the root directory, but i want to give it a folder name (that exists of course) and make it ouput that full path
I would amend your code slightly, see if you can spot the difference:
Code: Select all
<?php
$myfolder = "graphics";
if ($handle = opendir($HTTP_SERVER_VARS['DOCUMENT_ROOT'])) {
echo "Files:<br>\n";
while ($file = readdir($handle)) {
$mydir = dirname($file);
$mydir = $mydir."/".$graphics;
$file = basename($file.".htm");
echo "$file\n";
echo "$mydir\n";
}
}
?>
Thanks, that works too, but I just realized, I 've been going around in circles...the var $file contains files in the ROOOT directory...I was trying to get the root directory so I can append the graphics directory to it..and THEN read off the file names in $graphics.... NOW that would solve the real issue??? Eventually, I would want to only change the var $graphics and be able to use this page anywhere ....
I tried this.. but of course as a newbie..it didn't work:
opendir($HTTP_SERVER_VARS['DOCUMENT_ROOT']."/".$graphics))
Any ideas?[/quote]
IF you want to read the the graphics directory just do this
Code: Select all
<?php
$myfolder = "graphics";
if ($handle = opendir($HTTP_SERVER_VARS['DOCUMENT_ROOT'].$myfolder)) {
echo "Files:<br>\n";
while ($file = readdir($handle)) {
print "$file<br>\n";
}
}
?>