Okay well! this page is real helpfull if you want to display a bunch of downloads without needing an sql table, and without having to update the index page
Paste this into a file "index.php" in a NEW directory. something like /downloads or someting then place the link into "opendir" i have no idea if just / will cut it. i use the full path /www/home etc..
Then all you need to do is upload files into the directory! and they will display. the file sizes will also display underneath each file.
For an example of this; go here: http://wfs.myartsonline.com/downloads
i find this SO usefull to have a simple page which can display what i need w/o having to update it all the time and displaying the size too. hope ya enjoy!
Also, this was my first go with regular expressions in PHP. Hope they work okay! as far as i have tested they work fine. it will display ANY file in the directory EXCLUDING .php files
For a good tutorial i have posted the link in the PHP forums, go check it out here: http://www.hawkee.com/phpBB2/viewtopic.php?t=18120
<?php
if ($handle = opendir('/')) {
while (false !== ($file = readdir($handle))) {
if (!preg_match("/\.(.?|php)$/",$file)) {
echo '<a href="' .$file. '">' .$file. '</a><br>';
$size = round(filesize($file) / 1024, 2);
echo '<font style="font-size:11px;">File Size: ' .$size. 'KB;</font><br>';
}
}
closedir($handle);
}
?>
Nice little script. The display kinda reminds me of an XLST'd XML file.
Anyways, take a peek at scandir(), I think it might make the code a little simpler and faster to process: http://php.net/manual/en/function.scandir.php
Hope I helped
Hi weaver, something isn't "wrong", unless PHP has somehow drastically changed. i'm afraid to say, as much as i like to vent my frustration on code, this is not one of the cases. Check the link, the code still works there :)
Can you confirm that you have changed the directory you are searching through?
Its not exactly a "Download Script" as such, more of a, List of Downloads. A "Download Script" would be, the page loads, clicking on an item, forces it to download (Good ol' Ajax will help)... but never the less, helpful to some young ones....
Rating: 7.5 (Roudning it up to an 8 for the Rating part)