我有一个联系表单,用于在客户端邮件中发送图像div
<form name="form" method="post" action="mail.php" id="myForm">
</form>
表单由输入类型提交
提交<input name="submit" type="submit" value="Submit" id="capture" />
我发送电子邮件的PHP是
<?php
include("auth.php");
//message
$message = $_POST['msg'];
$username =$_REQUEST['username'];
$surname =$_REQUEST['surname'];
$name= $_REQUEST['name'];
$filename = md5(uniqid(rand(), true));
$imageurl = 'http://panosmoustis.netai.net/barcodeimage/'.$filename.'.png';
//mail body - image position, background, font color, font size...
$body = "Dear $surname $name
Thank you for your Pre-registration for Global.
Please print the attached e-ticket with your personal barcode and bring it to the reception of the exhibition.
This barcode includes data about you which is required during registration. Having this barcode will considerably speed up the registration process
Organizing committee.\n".
$body = "Print e-ticket
$imageurl.\n".
//to send HTML mail, the Content-type header must be set:
$headers='MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html;charset=iso-8859-1' . "\r\n";
$headers .= 'From: <http://panosmoustis.netai.net/>' . "\r\n";
$to = $_POST['mail'];
$subject = "EXPRESS REGISTRATION (Global)";
//mail function
$email = mail($to, $subject, $body, $headers);
if(!$email) {
echo "Error sending email";
} else {
echo "Your email was sent successfully.";
}
?>
然后我有一个ajax函数用于在服务器上保存动态创建的图像
<script>
$("#capture").click(function() {
html2canvas([document.getElementById('printableArea')], {
onrendered: function (canvas) {
var imagedata = canvas.toDataURL('image/png');
var imgdata = imagedata.replace(/^data:image\/(png|jpg);base64,/, "");
//ajax call to save image inside folder
$.ajax({
url: 'save_image.php',
data: {
imgdata:imgdata
},
type: 'post',
success: function (response) {
console.log(response);
$('#image_id img').attr('src', response);
}
});
}
})
});
</script>
用于在服务器上保存图像的我的php文件
<?php
$imagedata = base64_decode($_POST['imgdata']);
$filename = md5(uniqid(rand(), true));
//path where you want to upload image
$file = '/home/a7784524/public_html/barcodeimage/'.$filename.'.png';
$imageurl = 'http://panosmoustis.netai.net/barcodeimage/'.$filename.'.png';
file_put_contents($file,$imagedata);
echo $imageurl;
我的问题是我想在表单提交时将imageurl发送到电子邮件客户端 谢谢
答案 0 :(得分:0)
$imageurl = 'http://panosmoustis.netai.net/barcodeimage/'.$filename.'.png'
这里使用了字符串连接。
但是你没有:
$body = "Print e-ticket $imageurl.\n".
您只需执行与使用随机文件名创建$ imageurl时相同的操作:)