Auto start file download after form submission

Asked
Active3 hr before
Viewed126 times

6 Answers

start
90%

Meta Stack Overflow ,Stack Overflow en español,Stack Overflow em Português, Stack Overflow Public questions & answers

You could send the form to the Thank you document and put there a META refresh to the file download:

<meta http-equiv="refresh" content="3;url=download.php">
<p>Thank you! The download will start in 3 seconds. If not, use this link to download the <a href="download.php">file</a></p>
load more v
88%

I have a web form that users complete online. When they press submit it will start a file download for them.,At the moment, I process the form submission and generate a suitable file for the user and fire it off with suitable headers. eg...,The --continue makes it easier to restart a stalled/dead download.,The -P makes it easy to restart a stalled/dead download.

At the moment, I process the form submission and generate a suitable file for the user and fire it off with suitable headers. eg...

header('Content-type: "application/octet-stream"');
header('Content-Disposition: attachment; filename="yourfile.txt"');
header("Content-Transfer-Encoding: binary");
load more v
72%

I can add a simple download link in the post-submit HTML, but this is an extra click for the user and potentially confusing after they've already clicked 'Download'. , Thank you for the code. It's working. But i want to download the file once the form is filled and submit button is clicked. Is it possible to do that?? ,So, I'd like the PDF to be automatically downloaded when the form is submitted. , I got this working with the following code in form post-submit HTML

I got this working with the following code in form post-submit HTML

<script>
   var link = document.createElement('a');
   link.href = '/s/filename.pdf';
   link.download = 'filename.pdf';
   link.dispatchEvent(new MouseEvent('click'));
</script>
load more v
65%

Firstly, create a form with the hidden submit button.,Create a button outside the form and also give it a unique id to access it.,Approach 1: Creating submit form button outside the form:,After that, we simply call the submit event on the form to submit it, after triggering the download from the element we created.

75%

Downloading file after form submission ,Im am trying to force a file download after user submits a form. When user hits submit button POST data are send to a template (sort of "thank you for downloading" page). This template on successful submission redirects to another template through this code,Redirection then hits this template code (located in download template):,However, I got a little class that works pretty well for download files. Without getting headache.

Im am trying to force a file download after user submits a form. When user hits submit button POST data are send to a template (sort of "thank you for downloading" page). This template on successful submission redirects to another template through this code

< ? php
$downloadurl = $pages - > get('/download/') - > url;
header('refresh: 0; url='.$downloadurl); ?
>

Redirection then hits this template code (located in download template):

< ? php
// filename & url of the pdf file
$filename = $pages - > get('/some-page/') - > file - > name;
$fileurl = $pages - > get('/some-page/') - > file - > url;
$filesize = $pages - > get('/some-page/') - > file - > filesize;

// force download of the file
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename='.$filename);
header("Content-Length: ".$filesize);
readfile($fileurl);
load more v
40%

Want extra lead generation on your WordPress site? Offer file downloads after form submission! Just create forms that require email to download files. Here's the perfect email before download plugin.,Then feel free to add whatever fields to the form you want. This is the form where users submit information to receive a download.,You did it! Now you should have a fully functioning form that requires an email to download a file, giving new subscribers access to your gated content.,The next step is to show them the downloadable file after they give you their email address. This is where the whole idea of offering the files is put into action.

In the content box, click on the Text tab instead of Visual. You’ll need to enter some HTML to create a link to the download:

 <a href="[x]">Open [y]</a>
load more v

Other "start-undefined" queries related to "Auto start file download after form submission"