Click to See Complete Forum and Search --> : I want to open a directory structure...
how do I list directories as hyperlinks, then when clicking on them, branching out the files...
also, can I do a page count in a directory? .. meaning can I count the number of pages/files in each directory? ...
thanks in advance.
-eyal.
Here is the code that I use in a log file import script that I run...
<%
if (strlen("$QUERY_STRING")==0){
$diropen="/opt/data/pxlog";
}
else {
$r=split("=","$QUERY_STRING");
$diropen=$r[1];
}
print "<h1>Import Data from $diropen</h1><p> </p><p> </p>";
if ($r[0]=="dir" || $diropen=="/opt/data/pxlog"){
if (chdir("$diropen")){
$d=dir('.');
while ($what=$d->read()){
if (is_dir($what)){
$f=getcwd();
print "<a href='import.php?dir=$f/$what'>$what</a><br>";
}
else {
$f=getcwd();
print "<a href='importlog.php?file=$f/$what'>$what</a> ".filesize($f.'/'.$what;
}
}
}
}
%>
Hope this helps!
- Kevin
thanks a lot!!! ...
I modified it a bit.. so it works in any directory ... and I also got it to organize better...
check it out ..
---------------------------------------------
<head>
<title>Untitled</title>
</head>
<body>
<ul>
<?
if (strlen("$QUERY_STRING")==0){
$diropen=".";
}
else {
$r=split("=","$QUERY_STRING");
$diropen=$r[1];
}
print "<li><h1>Import Data from $diropen</h1></li>";
if ($r[0]=="dir" || $diropen=="."){
if (chdir("$diropen")){
$d=dir('.');
while ($what=$d->read()){
if (is_dir($what)){
$f=getcwd();
print "<li><a href='$PHP_SELF?dir=$f/$what'><FONT COLOR=RED SIZE=3><B>$what</B></FONT></a></li>";
}
else {
$f=getcwd();
print "<li><a href='$PHP_SELF?file=$f/$what'>$what</a></li>
".filesize($f.'/'.$what);
}
}
}
}
?>
--------------------------------------
ps.
I forgot all about the <? ?> ... and the <% %> .... and I freaked out when the code was printed in the src code ... lol ;-)
have fun with it!
or actual ... for the code to show up here in the web form ... try this code ...
-------------------
<head>
<title>Untitled</title>
</head>
<body>
<ul>
<?
if (strlen("$QUERY_STRING")==0){
$diropen=".";
}
else {
$r=split("=","$QUERY_STRING");
$diropen=$r[1];
}
print "<li><h1>Import Data from $diropen</h1></li>";
if ($r[0]=="dir" || $diropen=="."){
if (chdir("$diropen")){
$d=dir('.');
while ($what=$d->read()){
if (is_dir($what)){
$f=getcwd();
print "<li><a href='$PHP_SELF?dir=$f/$what'><FONT COLOR=RED SIZE=3>h;<B>$what</B></FONT></a></liNgt;";
}
else {
$f=getcwd();
print "<li><a href='$PHP_SELF?file=$f/$what'>$what</a></li>
".filesize($f.'/'.$what);
}
}
}
}
?>
</body>
-------------------------
hope I got all of them ...
(just incase i didn't:
I used <UL> to start an Unorderd List
then I added a <LI> - Line for each print function...
dressed it up with a few font features; <B> and <FONT> ... and vuala! )
-enjoy!
PHP Builder
Copyright WebMediaBrands Inc. All Rights Reserved.