It depends what it's for and what the file contains 😃
Storing in a database means there's no need to have write access to your server - which helps security
Storing in a file makes it easier to access the file in other ways than via a browser (e.g. via FTP)