List Everything In Folder (PHP)

03-06-06, 05:05 PM
|
|
Newbie Coder
|
|
Join Date: Mar 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
List Everything In Folder (PHP)
I need a simple script that lists all the files in a specific folder. For example, I have a folder on my website filled with pictures. I need a script that will list all the names of the files/pictures in my folder since my folder is not public.
If someone could make this, I would be extremely grateful!
Thanks
P.S. If something simple like this already exists, please provide a link if possible.
Last edited by IKG; 03-06-06 at 05:07 PM.
|

03-06-06, 06:32 PM
|
|
Aspiring Coder
|
|
Join Date: Jan 2006
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
|
Originally Posted by IKG
I need a simple script that lists all the files in a specific folder. For example, I have a folder on my website filled with pictures. I need a script that will list all the names of the files/pictures in my folder since my folder is not public.
If someone could make this, I would be extremely grateful!
Thanks
P.S. If something simple like this already exists, please provide a link if possible.
|
The script above will list all the file names in a folder, I guess if you have pictures you wont want the .jpg to appear after it, you will have to substr() it.
|

03-06-06, 06:37 PM
|
|
Newbie Coder
|
|
Join Date: Mar 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Wow! Thanks so much!
Now how would I implement this?
I've made a .php file and placed it in the specified folder. This is what I have so far:
Update: I tried creating a HTML file with this code instead, but it still doesn't work. All I get is a blank, white, page.
Last edited by IKG; 03-06-06 at 06:54 PM.
|

03-06-06, 06:54 PM
|
|
Aspiring Coder
|
|
Join Date: Jan 2006
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
|
Originally Posted by IKG
Wow! Thanks so much!
Now how would I implement this?
I've made a .php file and placed it in the specified folder. This is what I have so far:
|
Yeah that should work then, does it?
|

03-06-06, 06:55 PM
|
|
Aspiring Coder
|
|
Join Date: Jan 2006
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
|
Originally Posted by IKG
Wow! Thanks so much!
Now how would I implement this?
I've made a .php file and placed it in the specified folder. This is what I have so far:
Update: I tried creating a HTML file with this code instead, but it still doesn't work. All I get is a blank, white, page.
|
Thats strange, just try the PHP code on its own. Call the file test.php or something.
Also on the example you used above i noticed that the <?php code ?> was not in the <body> </body> tags.
<body>
<?php
//code
?>
</body>
That might be the problem.
Just try the code in a seperate file first tho. (.php)
|

03-06-06, 07:55 PM
|
|
Wannabe Coder
|
|
Join Date: Dec 2005
Location: Texas
Posts: 111
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
His problem is that he made it an HTML file.
|

03-06-06, 08:35 PM
|
|
Newbie Coder
|
|
Join Date: Mar 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
No, I tried making it a .php at first but it didn't work. Now I tried again and still no luck. Just a blank white page...
By the way, even if I get this to work will I be able to make the words link to the file?
Last edited by IKG; 03-06-06 at 08:40 PM.
|

03-06-06, 10:12 PM
|
 |
Community VIP
|
|
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
It is highly likely that the path to the directory, from the current location where the php script is running, is not correct. Your code could use some error checking (always a good idea, and certainly a good idea when debugging a problem.) Try the following to see if it is even finding and opening the directory -
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
|

03-06-06, 10:20 PM
|
 |
Community VIP
|
|
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
It took me a second to figure out what this meant -
Quote:
|
By the way, even if I get this to work will I be able to make the words link to the file?
|
To make the file names into clickable links, change the echo statement in the middle of the loop to -
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
|

03-14-06, 04:48 PM
|
|
Newbie Coder
|
|
Join Date: Mar 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
@ Mab: I tried what you suggested and got the "could not open" error listed. I also tried making it just "endicott/" but no luck...
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|