我正在使用phpmailer通过电子邮件发送我的表单详细信息,它有一个名称字段和一个fil上传字段,并希望附加名称和视频并使用phpmailer通过电子邮件发送,这是我使用的示例代码。 / p>
html表单
<form action='<?php bloginfo('template_directory'); ?>/upload.php' method='post' enctype="multipart/form-data">
<div class="col-md-12">
<div class="inner-addon left-addon col-md-3 col-sm-12 col-xs-12" style="display : inline-block">
<i class="glyphicon glyphicon-user"></i>
<input type="text" name="name" placeholder="Full Name" class="form-control"style="padding-left: 35px;font-size: 14px;" required/>
</div>
<div class="col-md-12" style="padding : 0px !important">
<div class="inner-addon left-addon col-md-3 col-sm-12 col-xs-12" style="display : inline-block; padding:0px !imporant;" >
<div class="col-md-8 col-sm-8 col-xs-8" style="padding:0px;">
<input id="uploadFile" class="form-control" placeholder="Choose File" disabled="disabled" style="border-radius: 4px 0px 0px 4px; background-color: #fff;"/></div>
<div class="col-md-4 col-sm-4 col-xs-4" style="padding:0px !important"><div class="fileUpload btn btn-primary" style="margin:0px !important; height:45px;width:100%; border-radius: 0px 4px 4px 0px; background-color:#9177ad; border : 1px solid #9177ad;">
<span style="line-height: 2.428571;">Upload</span>
<input id="uploadBtn" name="fileToUpload" type="file" class="upload" required />
</div></div>
</form>
upload.php的
<?php
require __DIR__ . '/PHPMailer/PHPMailerAutoload.php';
$name = $_POST["name"];
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.mandrillapp.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'user@rmail.com'; // SMTP username
$mail->Password = 'password'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;
$mail->setFrom('email', 'email');
$mail->addAddress('email@email.com', 'name'); // Add a recipient
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $name;
$mail->Body = 'hi';
if (isset($_FILES['fileToUpload']) &&
$_FILES['fileToUpload']['error'] == UPLOAD_ERR_OK) {
$mail->AddAttachment($_FILES['fileToUpload']['tmp_name'],
$_FILES['fileToUpload']['name']);
}
if(!$mail->send()) {
error_log('Message could not be sent.');
error_log('Mailer Error: ' . $mail->ErrorInfo);
} else {
error_log('Message has been sent');
}
但问题是我无法从我的桌面附加视频,但它可以正常处理图像和文档文件。我试图回显视频的文件类型,它什么也没有返回。有人可以帮我解决这个问题。我试图回显视频的文件类型,但没有返回任何内容。
答案 0 :(得分:1)
在php.ini文件中,验证是否已设置以下内容:
memory_limit = 40M
post_max_size = 40M
upload_max_filesize = 40M
file_uploads = On