在联系表7 Wordpress中提交后下载文件 [英] Download File after submission in Contact Form 7 Wordpress

查看:67
本文介绍了在联系表7 Wordpress中提交后下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一种提供诸如用户输入姓名和电子邮件之类的功能的表格,然后自动开始下载PDF文件。

I am trying to make one form which give functionality like when user enter name and email,then PDF file starts download automatically.

在我应用此代码时在提交按钮的其他设置选项卡中,它重播此错误消息。

And while i am applying this code in additional setting tab on submit button,it replay the error message like this.

我目前在本地计算机上工作,我知道联系表格7邮件选项卡中有错误,

I am currently working in local machine, i know error is in contact form 7 mail tab,but don't know how to fix it?

尝试发送您的消息时出错,请稍后再试。

"There was an error trying to send your message. Please try again later."

这是我的联系表单7代码:

Here is my contact form 7 code:

<label> Name
    [text* your-name] </label>

<label> Email 
    [email* your-email] </label>

[submit "Download Now"]

这是我写的代码在附加设置中,可在提交表单后直接下载PDF文件

Here is code that i write in Additional Setting for download PDF file directly when form is submitted

on_sent_ok: "location = 'http://localhost/wordpress/wp-content/uploads/2017/08/pdf-sample.pdf';"


推荐答案

我找到了满足您需求的解决方案,请按照以下步骤操作,它无法发送邮件,但可以根据您的要求在本地计算机上正常运行。

I Found solution for your need,just follow below stops,it can not send mail,but works fine in local machine as per your requirement.

1)只需将以下代码粘贴到联系表7中的其他设置标签中

1) Just paste below code in your Additional Setting tab in contact form 7

demo_mode : on

on_sent_ok: "location = 'http://localhost/wordpress/wp-content/uploads/2017/08/pdf-sample.pdf';"

2)将下面的代码放在.htacess文件中,在[/ IfModule]之后,并在#END WordPress以下

2) Put below code in your .htacess file, after [/IfModule] and below # END WordPress

<FilesMatch "\.(?i:pdf)$">
   ForceType application/octet-stream
   Header set Content-Disposition attachment
</FilesMatch>

这篇关于在联系表7 Wordpress中提交后下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆