PDA

View Full Version : How to maintain links to files efficiently?



avipre
21 Mar 2007, 08:46 PM
Hi, I made a webpage with links that linked to over hundreds of PDF files. At first I make each PDF a link on my page but now I feel it's a bad idea when comes to updating modified or new PDF file. What kind of method should I use to maintain the updates efficiently?

Thx in advance..

bjk2007
31 Mar 2007, 02:55 PM
Make a php script to have it list all the .pdf files in your pdf directory. That way you won't have to worry about it not being up to date. All it takes is something like this:


<?php
$pdfs = scandir('pdf/directory/');
foreach ($pdfs as $v)
{
if ((stripos($v,'.pdf') !== false) && (strpos($v,'.') !== 0))
{
echo '<a href="pdf/directory'.$v.'">'.$v."</a>\n";
}
}
//Unless server is still on PHP 4, then things get more complicated as you'll have to make your own scandir function and will have to use strpos instead of stripos. Use phpinfo() to determine server information (unless that has been disabled too).
?>