For #2, I don't have any tutorials that I know of. But its really pretty easy - even easier than working with a database, if you ask me.
First, do your authentication:
- make sure the user has access to the file
- make sure the user is requesting a file that exists (check that there's a record of the file in the database and if you want your app bullet proof, do a [man]file_exists[/man])
After authentication, figure out what content headers you need to send.
It might look something like this:
header('Content-type: application/vnd.ms-excel'));
header('Content-Disposition: attachment; filename="filename.xls"');
Trick is you'll have to determine it from the file or save it as a field in your database.
Send the header out. Then its a matter of reading the file in and dumping it out to the user. That's pretty easy and there's a few ways to do it. One is with [man]fopen[/man] and a while loop. The other is [man]readfile[/man] which might be perfect for what you're doing.
And that's really about it. You'll want this to be a seperate PHP file. For the download link, you just point the user to your PHP file and it does the rest (if its working, you should see a download dialog box popup and ask you what you wish to do with the file download that's about to start).