Best way to serve/upload documents

Maybe you should use HTTP realms based authentication.

This will solve both of your issues, I believe.

Google is your friend.

Julian.