Hi everyone, I have this form that users have to fill out in order to get to a free download. Instead of just sending them to www.domain.com/file.pdf, I would like to create a temporary fie with an expiring name so that they can't just download the file anytime they want. So in short, this is what I want: User signs up The file is created, email is sent. The user gets email with download link. The user downloads the file. The file and link are destroyed. How can I accomplish this? Thanks so much for the helps!
I think you may be going about this wrong. Instead of creating a temp file (unless you absolutely have to because the file is dynamically generated), send them a link with a random value that your code translates into the file you want to download and send it to them by streaming the file (with the proper headers preceding the stream, so that the file comes out like a stream and not like junky HTML).
Thanks amf-flt- I think you may be right about me going about it wrong. could you expand a little bit about the "send them a link with a random value that your code translates into the file you want to download and send it to them by streaming the file (with the proper headers preceding the stream, so that the file comes out like a stream and not like junky HTML)." part? Thanks!
When someone wants to download (after payment I assume) generate them a random number and stick it in a database. After doing this on the server, send the downloader an email with a link to get the file. When the downloaded clicks the link, delete the record from the database and give them access to the file. By doing this, next time they click the link in the email (or try to access the page directly) the database will not contain a code and the process will error out however you want it to. This is a pretty simple process but would contain a fair amount of custom coding for your server (db setup, mail to user, etc.) so I doubt you will be getting code in this thread ... but someone might proove me wrong.
Tackling it in Pseudo code! First you need the file you want to download... File1.jpg Now you have someone that wants to download the file, but you want to make sure they do something first... Never offer the file directly. Always offer it 'through' PHP by dumping the file into the browser. You give the user a download link like www.whatever.com/download.php?id=ASsdva4124ABG and that crazy id (or any id) will have a record in the database pointing to the file. All you need to do is mark the record as used and dump the file.
Thanks guys, I appreciate it! ErectADirectory: I was looking for some help with the logic here and that's what I got from you guys. Thanks again! Will get to work on this bit soon!!