Google Answers Logo
View Question
 
Q: Display and Link for Download, Files from a Folder within a Web Site ( No Answer,   1 Comment )
Question  
Subject: Display and Link for Download, Files from a Folder within a Web Site
Category: Computers > Internet
Asked by: mclinn-ga
List Price: $20.00
Posted: 11 Jul 2006 10:34 PDT
Expires: 19 Jul 2006 10:38 PDT
Question ID: 745331
Problem: 
I have a set of PDF files that are uploaded monthly to a folder on a
website I support. These files change in name, size, and number of
files each month. I need a script that will display on my webpage, the
file name, and act as a link so that the user can access them.
Note: 
While I dont care what kind of scrip it is, I dont have access to the
server which hosts the files other than via FTP. So the scrip needs to
reside in an html file, php, or java script as far as I know.
Additional Note:
The site page is: http://www.venturapublishing.com/listings.html
As you can see, I've manually linked all the PDF files from their
folder. I would expect the scrip to simply to do what I did, but
automatically when files are uploaded.

Clarification of Question by mclinn-ga on 12 Jul 2006 16:35 PDT
Thanks for the comment, however my server does not support PHP after
looking into it. So if anyone does attempt to answer the question,
please do not provide an answer that includes PHP.
Thanks

Request for Question Clarification by eiffel-ga on 14 Jul 2006 01:26 PDT
Hi mclinn-ga,

We really need to know what scripting languages the server supports:
Perl, PHP, Python, ruby etc.

For example, if it supports the ruby language I'd be delighted to
answer this question.

Regards,
eiffel-ga

PS: I don't think you can read local folders from JavaScript.
Answer  
There is no answer at this time.

Comments  
Subject: Re: Display and Link for Download, Files from a Folder within a Web Site
From: pjdoland-ga on 12 Jul 2006 12:08 PDT
 
If your server supports PHP, you should just be able to paste this
into the page, and rename the file extension.php

<?

$directory = opendir("./") or die($php_errormsg);
while (false !== ($file = readdir($directory))) {
        $directory_files[] = "$file"; 
}

sort($directory_files);

$script_name = $_SERVER['SCRIPT_NAME'];

$dirlist = "";

foreach ($directory_files AS $file) {
        if ((!preg_match("/^\..*$/i", $file)) AND ($file != $script_name)) {
                $dirlist .= "      <li><a href=\"$file\">$file</a></li>\n"; 
        }
}

if ($dirlist) {
        echo "  <div class=\"filebox\">\n    <h3>Files</h3>\n   
<ul>\n$dirlist    </ul>\n  </div>\n";
}

?>

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy