【发布时间】:2017-03-07 01:04:39
【问题描述】:
我在我的 Wordpress 主题中使用自定义表单 这是我的表格
HTML
<form accept-charset = "UTF-8" action = "https://forexmplesecondsite.com/get_form_data" method = "POST" target = "_blank" enctype="multipart/form-data">
<label for="customer-name"> your name *</label>
<input type="text" id="customer-name" name="customer-name" />
<label for="company-name"> your company name *</label>
<input type="text" id="company-name" name="company-name" />
<input type="file" name="customer-logo" />
<input type="submit" value="upload" id="upload-form">
</form>
jQuery
jQuery(document).ready(function ($) {
$("#upload-form").click(function(){
<?php
$to = 'mymail@email.com';
$subject = "my mail subject";
$message = "please check logo attachment";
$headers = array(
‘From: My Name <myname@example.com>;',
'BCC: My Other Name <myothername@example.com>;',
);
$attachments=$_FILES['customer-logo']['tmp_name'];
wp_mail( $to, $subject, $message, $headers , $attachments );
?>
});
});
当有人点击提交时,表单重定向到其他网站,我收到了邮件,但我看不到任何附件。
【问题讨论】:
-
你是 php 新手,我可以看到 :)
-
您需要处理上传的文件(
move_uploaded_file( $tmpname, $target ))并使用$target作为附件
标签: php jquery wordpress forms email