Page 1 of 1

File Download Confirmation Page

Posted: Mon Nov 13, 2006 3:49 pm
by shiznatix
Ok so I have a thing where you can download a file that you select. You can only start the download if you fill out the form first. Fine, dandy, good to go!

Now the problem is that I want to have it so that after I check all the post data, if it was good stuff they sent in then it displays a message like 'Thanks for the info!' then it starts the download. Now I can not come up with a logical way to do this without using javascript to open the last page (the page that starts the download).

Is there a way to do this without using javascript? I don't want the file path to be shown or easily gotten by a user as to keep the files location secret (sneaky huh?).

Posted: Mon Nov 13, 2006 4:33 pm
by feyd
meta tag redirection.

Posted: Mon Nov 13, 2006 8:49 pm
by aaronhall
If you want to be sneaky, you can insert a randomly generated string into the database after the user completes the forum. Display the thank you message and meta-redirect to another page that takes that unique code as a paramater (download.php?code=$randomString&file=$getFile). In download.php, verify that the $randomString exists in the DB, open $getFile from it's real location with file_get_contents and dump it back to the browser. Make sure you include the correct Content-Type header in download.php. Delete the code from the database after download.php is accessed. The file's actual location will never be visible to the client, and download.php will be 99.999% secure (short of guessing the random string immediately after someone completes the form).