"Hello,
i am trying to list the contents of a direcotry based on whether it is a file or dir but i am having a problem and i cna tidentitfy it
CODE_--------
if ($AUTH !== ("level1" || "admin"))
{
while(list($k,$filename)=each($DIRFILES))
{
if(is_file($filename)){
echo "<a href=index.php?filename=".$filename."&download=true>".$filename."</a><br>";
}
}
}
-------------
the thing is based on the $AUTH variable if it didnt match i would print out the files and not the direcotry
but i dont get anything
if i were to remove the (is_file()) i would get the listing of everything
what seems to be the problem here cause i dont get it
Kendall
list direcotry problem using is_file and is_dir
Moderator: General Moderators
- kendall
- Forum Regular
- Posts: 852
- Joined: Tue Jul 30, 2002 10:21 am
- Location: Trinidad, West Indies
- Contact:
is_file is_dir() problem
Yes everything is being read by the readdir function
No i dont want to list the full path just the file
but the problem is
it lists the files and directories
and i don't want it to do that just list the files
see if i took out the is_file() it works fine
but if i use is_file() why does it list directories?
Kendall
No i dont want to list the full path just the file
but the problem is
it lists the files and directories
and i don't want it to do that just list the files
see if i took out the is_file() it works fine
but if i use is_file() why does it list directories?
Kendall
is it because you are using $filename. which everything has a filename.
when I use readdir I usually refer to the $file
Steve
when I use readdir I usually refer to the $file
Code: Select all
if (is_file($file))try ...
$path being the the variable containing the path to the directory you are listing.
you made need to put a slash between $path and $filename depending on whether or not it is already on the end of the $path variable.
Code: Select all
if(is_file($path.$filename)){
echo "<a href="index.php?filename=".$filename."&download=true">".$filename."</a><br>";
}you made need to put a slash between $path and $filename depending on whether or not it is already on the end of the $path variable.
- kendall
- Forum Regular
- Posts: 852
- Joined: Tue Jul 30, 2002 10:21 am
- Location: Trinidad, West Indies
- Contact:
HEY
the ($path.$file) thing worked
but this now brings me to a more difficult problem
if am going deeper into directories and sub directories how do i get the paths then?
what is the exact use of realpath()?
im trying to get the path info with out having to reveal the absolute paths
any advice
Kendall
the ($path.$file) thing worked
but this now brings me to a more difficult problem
if am going deeper into directories and sub directories how do i get the paths then?
what is the exact use of realpath()?
im trying to get the path info with out having to reveal the absolute paths
any advice
Kendall