Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-15-2012, 11:30 AM   PM User | #1
alandor
New to the CF scene

 
Join Date: Feb 2012
Location: Sweden
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
alandor is an unknown quantity at this point
Display folder content on site

Hi,
I'm workning on a site where my client wants a page with a bunch of reports in pdf-format available for download. He'd like to just be able to put all of these pdfs in a folder on the server and have them automatically added to the html of the given page. (It needs to be easily updated with new reports.)

Is this easily done with php? My php knowledge is very limited but I imagine I can't do it with javascript.

I'm using drupal and found that the file_scan_directory function might be what I'm looking for but I'm not sure how to implement it.
alandor is offline   Reply With Quote
Old 02-15-2012, 12:32 PM   PM User | #2
litebearer
Regular Coder

 
Join Date: Apr 2004
Posts: 287
Thanks: 0
Thanked 21 Times in 21 Posts
litebearer is on a distinguished road
might look at this ...
http://www.nstoia.com/toh/listdir.php
litebearer is offline   Reply With Quote
Users who have thanked litebearer for this post:
alandor (02-18-2012)
Old 02-18-2012, 08:24 AM   PM User | #3
alandor
New to the CF scene

 
Join Date: Feb 2012
Location: Sweden
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
alandor is an unknown quantity at this point
Thanks. I've been looking at this but can't figure out how to implement it in my page. If I wanted to add this function to one of my pages I imagine I would have to include this .php file in that page's html. But what then? Should I call the function dir_list($dir) from a php snippet in my html doc? And what value should the $dir parameter have?
alandor is offline   Reply With Quote
Old 02-18-2012, 06:47 PM   PM User | #4
alandor
New to the CF scene

 
Join Date: Feb 2012
Location: Sweden
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
alandor is an unknown quantity at this point
Great. I finally had the time today to try this script and it works by just pasting the whole thing into my html file. Probably violates every coding praxis there is but it seems to work.

However, it would be less cumbersome if I could have this code in it's own php file and just call it by a simple function call from the html file. How would I do this? I just think it would make the html file more readable.
alandor is offline   Reply With Quote
Reply

Bookmarks

Tags
download, drupal, file, file_scan_directory

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:58 AM.


Advertisement
Log in to turn off these ads.