【发布时间】:2017-08-28 10:43:04
【问题描述】:
我有一个带有文件上传字段(CV 上传)的联系表。
我可以让邮件和消息发送没有问题,但是,我从网上使用的示例从表单中附加简历并不起作用。
这里有什么我遗漏的吗?
<input type="text" name="fullName" placeholder="Full Name: (required)" required>
<input type="email" name="email" placeholder="Email: (required)" required>
<input type="tel" name="tel" placeholder="Telephone: (required)" required>
<textarea name="message" placeholder="Quick message"></textarea>
<span>Please upload a copy of your cv</span><span><input type="file" name="cv" required></span>
//Handle the file upload and attachment
if ( ! function_exists( 'wp_handle_upload' ) ) {
require_once( ABSPATH . 'wp-admin/includes/file.php' );
}
$uploadedfile = $_FILES['cv'];
$upload_overrides = array( 'test_form' => false );
$movefile = wp_handle_upload( $uploadedfile, $upload_overrides );
if ( $movefile && ! isset( $movefile['error'] ) ) {
$movefile['url'];
}
$attachments = array($movefile['file'] );
$mailoffice = wp_mail('james1@knoppysdev.com', 'New Candidate Application', $messageOffice, $headers, $attachments );
【问题讨论】:
-
定义“不工作”
-
邮件发送所有邮件内容和表单中的发布值。但是文件附件的 PHP 不包含附件。
-
很确定
wp_mail只需要一个文件名数组...而wp_handle_upload返回的内容有所不同。
标签: php wordpress phpmailer email-attachments