View previous topic :: View next topic |
Author |
Message |
Flux -
Joined: 13 Oct 2006 Posts: 48
|
Posted: Mon Feb 12, 2007 9:57 am Post subject: Directory listing |
|
|
Pretty standard, right?
So I've tried to use a directory script with a $_GET so that I can just define what directory in a querystring. But anything other than the folder the script file (I named it dir.php) is in, and it gives me a:
Warning: opendir("<whatever directory i try to open>") [function.opendir]: failed to open dir: Invalid argument in F:\dir.php on line 6.
Here's my entire script:
Code: | <?php
// directory path can be either absolute or relative
$dirPath = $_GET['dir'];
// open the specified directory and check if it's opened successfully
if ($handle = opendir($dirPath)) {
// keep reading the directory entries 'til the end
while (false !== ($file = readdir($handle))) {
// just skip the reference to current and parent directory
if ($file != "." && $file != "..") {
if (is_dir("$dirPath/$file")) {
// found a directory, do something with it?
echo "[$file]<br>";
} else {
// found an ordinary file
echo "$file<br>";
}
}
}
// ALWAYS remember to close what you opened
closedir($handle);
}
?> |
Is there any file permission setting I have to change?...because I can do anything with the files and folders on my server EXCEPT see them on an automatically generated webpage.
Also, if/when this is solved, how does one add the url to the file or directory corresponding to it?
Ideally, I want this to work just like the "Standard Directory Listing" provided with Abyss Web Server, but the problem is that I would like to add in a necessity to log in, and be able to use a universal database (In my case, a MySQL database) which is why I'm working with php for a directory listing script.
Of course, if anyone knows of any script available from someone who already duplicated Abyss' directory listing ability in a .php file, please direct me to it. _________________ My signature is so lame.
I think phpBB forums hates my laptop '.'; |
|
Back to top |
|
 |
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Mon Feb 12, 2007 3:21 pm Post subject: Re: Directory listing |
|
|
Flux,
The parameter sent to opendir() should be a full directory path (on Windows it should look like C:/test/dir1/dir2). _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
 |
Flux -
Joined: 13 Oct 2006 Posts: 48
|
Posted: Mon Feb 12, 2007 9:24 pm Post subject: |
|
|
Meaning that if I use the same script that i posted up before, I should have a url:
http://site.com/dir.php?dir="F:\files\"
If I want to browse the equivalent of http://site.com/files/ ?
Or is it just:
http://site.com/dir.php?dir="/files/" ?
It does, at least, open up the directory that the script file is located in... _________________ My signature is so lame.
I think phpBB forums hates my laptop '.'; |
|
Back to top |
|
 |
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Tue Feb 13, 2007 11:28 am Post subject: |
|
|
Flux,
You script as it is written requires that you call it using something like http://site.com/dir.php?dir=F:\files\ . If you need a better way to enter paths, you'll have to tweak your code. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
 |
pkSML -
Joined: 29 May 2006 Posts: 955 Location: Michigan, USA
|
Posted: Tue Feb 13, 2007 11:36 pm Post subject: Re: Directory listing |
|
|
Flux wrote: | Of course, if anyone knows of any script available from someone who already duplicated Abyss' directory listing ability in a .php file, please direct me to it. |
http://stephen.calvarybucyrus.org/code/3
Just take out the first 12 or so lines (first PHP code block). _________________ Stephen
Need a LitlURL?
http://CodeBin.yi.org |
|
Back to top |
|
 |
Flux -
Joined: 13 Oct 2006 Posts: 48
|
Posted: Wed Feb 14, 2007 12:45 am Post subject: |
|
|
Oh, perfect. :D
Thanks a lot pkSML. _________________ My signature is so lame.
I think phpBB forums hates my laptop '.'; |
|
Back to top |
|
 |
|