I have a single php script on my site that facilitates my site’s downloads (logs user info, controls user permissions etc). A typical link looks like this on my site:
<a href="file_download.php?file_id=12345">Download file 12345</a>
In file_download.php I check to make sure the file request is valid, and if so, it does a header force file download
header("Content-type: application/force-download");
which forces the download prompt in the user’s browser. The user never leaves the page they click the link on.
What I am wondering is if I am able to toggle a jQuery event from file_download.php onto the parent page? It seems if I do anything on file_download.php other than a ‘header force download’ the user will leave the page.
Ideally I would like to keep my href links unchanged (for the sake of not editing a million instances site wide) and have file_download.php toggle a lightbox window prompting for user information before the download (if needed of course).
Any help or suggestions would be greatly appreciated, thanks.
You wouldn’t need to toggle the event from the PHP page, you could attach the information box to all of your download links, and then use JavaScript to redirect: