As the title suggests. I would like to give users the option to download invoices for purchases that have been made in the past. I would not like to store these files so that they are easily accessible via http, e.g. http://www.site.com/inv/567.pdf
.
I have thought of one way of doing this however i do not think that it is the best solution for this.
So in essence, I would have a folder on my server out of the public root and within this folder would be folders each with say a unique ID that relates to the customers account ID (MySQL row ID). Within each of these folders I could store the invoices or (.pdf files) relating to each customer.
I could build into the CMS for the admin a section that would deal with uploading these files to the various user accounts.
For the customer, when they click on the download button for any specific invoice, the server will copy the invoice to a temp directory in the public root but renaming it in the process to some obscure hash. The header is then directed to this location.
I could then run a cron job to clear this temp folder every x amount of time.
Given that I have never really attempted to accomplish this task before, I have thought it best to ask for any suggestions / feedback / advice or comments in relation to this as I am sure that you guys will have some good ideas on how to do this too. Thank you in advance for any assistance provided!