I'm kinda stuck at how about going to retrieve filenames...
this is wht I'd like to do..
I wanna display the file/folder names..
the folders are this way:
--> documents
--> new
--> file01.php
--> old
--> file02.php
--> file03.php
What I'd like is that the first display is
New
Old
then when i click on "New" it displays file01.php
or when I click on "Old" it displays file02.php, file03.php
I'd like to do this all in one php and place that php file in the documents folder...
Can anyone help?
So far.. I'm up to here:
Code: Select all
<?php
$base = "../document/";
$base_array = array();
if(is_dir($base)) // if it is a dir
{
$diropen = opendir($base); // open dir
while (false !== ($dir = readdir($diropen))) // stop when $dir=false
{
// get rid of the folders that need not be displayed
// if base.subdir name is a dir
if (is_dir($base.$dir) && $dir !== '.' && $dir !== '..' && $dir !== 'drop box' && $dir !== '.DS_Store')
{
$subs = $dir;
$subbase = strval($base.$dir."/"); // entire filename
//print "subbase: $subbase<br>";
print "<a href="$dir/">$dir</a><br>";
}
if(is_file($base.$dir) && $dir !== '.' && $dir !== '..' && $dir !== 'drop box' && $dir !== '.DS_Store')
{
$subs = $dir;
$subbase = strval($base.$dir); // entire filename
if(!strstr($dir, ".php")) // take out the .php files
{
}
}
}
closedir($diropen); // close dir
}
else // if it is not a dir
{
print "no dir";
next;
}
?>need help!!!
thanks