在表单提交上下载文件

在提交表单时,它应该下载文件并理想地重定向页面,这就是我正在尝试的内容</ p >

现在我正在使用hubspot表单我的代码看起来像这样只是提交表单并在表单提交时重定向到新页面。</ p>

 &lt  ; 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“&gt; 
&lt; h2&gt;外包计划模板&lt; / h2&gt;
&lt; div class = “col-md-6”&gt;
&lt; input type =“text”class =“form-control”required =“required”id =“firstname-84b04dc8-4a51-44cc-aa1d-036709bd681f”name =“firstname “placeholder =”Name“&gt;
&lt; / div&gt;
&lt; div class =”col-md-6“&gt;
&lt; input type =”email“class =”form-control“required = “required”id =“email-84b04dc8-4a51-44cc-aa1d-036709bd681f” name =“email”placeholder =“电子邮件地址”&gt;
&lt; / div&gt;
&lt; div class =“hs_submit”&gt;
&lt; div class =“actions”&gt;&lt; input class =“ btn btn-default“type =”submit“&gt;&lt; / div&gt;
&lt; / div&gt;
&lt; / form&gt;
</ code> </ pre>

现在下载 pdf文件我修改了代码中的第3行,如下所示:</ p>

 &lt; div class =“hs_submit”&gt; 
&lt; div class =“actions”&gt ;&lt; input class =“btn btn-default”href =“http://cdn2.hubspot.net/hub/462167/file-2150080411-pdf/High_freq.pdf”type =“submit”download&gt;&lt; / div&gt ;
&lt; / div&gt;
</ code> </ pre>

从以下位置获取参考:
如何在单击html按钮或javascript时触发文件下载 </ p>

同时提及 H. 我能提供PDF文件的直接下载链接吗?但是没有办法使用html或某些解决方案的下载标签吗?
谢谢提前</ p>
</ div>

展开原文

原文

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

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐