Download file on form submistion

1k views Asked by At

On submitting the form it should download the file and page gets redirected ideally, this is what I am trying

Now I am using hubspot form My code looks like this which is just to submit the form and redirecting to new page on form submittion.

<form accept-charset="UTF-8" enctype="multipart/form-data" id="hsForm_84b04dc8-4a51-44cc-aa1d-036709bd681f" class="hs-form stacked" action="https://forms.hubspot.com/uploads/form/v2/462167/84b04dc8-4a51-44cc-aa1d-036709bd681f" method="POST">
    <h2>The Outsourcing Planning Template</h2>
    <div class="col-md-6">
       <input type="text" class="form-control" required="required" id="firstname-84b04dc8-4a51-44cc-aa1d-036709bd681f" name="firstname"  placeholder="Name">
    </div>
    <div class="col-md-6">
       <input  type="email" class="form-control" required="required" id="email-84b04dc8-4a51-44cc-aa1d-036709bd681f" name="email"  placeholder="Email Address">
    </div>
    <div class="hs_submit">
       <div class="actions"><input class="btn btn-default" type="submit"></div>
    </div>
</form>

Now to download the pdf file I modified the 3rd last line in the code as below:

<div class="hs_submit">
   <div class="actions"><input class="btn btn-default" href="http://cdn2.hubspot.net/hub/462167/file-2150080411-pdf/High_freq.pdf" type="submit" download></div>
</div>

Took the reference from: How to trigger a file download when clicking an html button or javascript

Also referred How do I provide a direct download link to a PDF file? But is there no way to use download tag of html or some solution? Thanks in advance

0

There are 0 answers