read up on the DIR() function, and the header() function.
from there you should be able to make a script that can go through a directory, add the files to a database, and then another script that given a file id, can add 1 to a download count, and send the file through.