In your e.g., database, create a table which links an ID to a specific file on your server.
Then, when I user requests a file.php?id=2 you look for the fileame in the database. You then [man]readfile[man] to return the content to the user. Have a look at the manualpage I linked to. The usercontributions are helpfull.