Forum
Download file behind form
Hi there,
I have a client who wants some simple PDF files behind a form, as he wants to collect emails. I have made a list/detail template where he can add the files and some information. I've also made the form that will stand in front of the file. I know I can redirect a form upon submission but is it possible to send the user to a page where I could carry over the path to the download and serve it up for download or trigger the download on the dame page but only once the form has submitted?
I've just done this. It was for a site where the user needs to fill in their name, company and email address before they can access the report:
Hi Toby,
So it looks like you're redirecting them to a blog post, in your case a 'report'? Do you think this concept could deliver a file, rather than view something?
This redirects them to the pdf. The user can then decide whether to download it or just view it.
For context here is the
_report_link
template I'm using to get the url of the PDF:Here's the test site, feel free to fill in the form to test, the email just comes to me at the mo:
https://frukt.creativemonster.co.uk/insights/design-flavours-1
Thanks to Toby, I have a working solution where by a user completes the single field form and gets taken directly to the pdf in the browser.
I tweaked the code to try and force a download in the browser, which I have working. I am just wondering if it's possible to still get the form to show the success message as well as download the file? At the moment if you complete the form, you see the download prompt appear but no success message - I am guessing because I am firing off those new headers.
My code: