简体   繁体   English

图片上传无需FTP上传即可发送电子邮件

[英]Image upload send email without FTP upload

I am using jQuery and PHP in order to send a form as an email. 我正在使用jQuery和PHP来发送表单作为电子邮件。 Inside the form is an image upload. 表单内部是图像上传。 I want to include this image inside my email. 我想将此图像包含在我的电子邮件中。 I know that there are a lot of examples though every example is uploading the image to the FTP and then sends it as an email. 我知道有很多示例,尽管每个示例都将图像上传到FTP,然后将其作为电子邮件发送。 I want to send it directly without saving it somewhere... 我想直接发送而不保存到某处...

This is what I currently have: 这是我目前拥有的:

<form id="myform" method="post">
    <input id="Telefon" name="Telefon" type="text"></input>
    <input id="Email" name="Email" type="text"></input>
    ...
    <input id="fileupload" type="file" name="img" accept="image/*" multiple>
</form>

jQuery: jQuery的:

$.post( "action.php", $('#myform').serialize(),function( data ) {
  // bla bla 
});

PHP: PHP:

$Email = $_POST['Email'];
$Telefon = $_POST['Telefon'];

How can I access the image? 如何访问图像?

$receiver = "blabla@blabla.de";
$subject = "Bla Bla";
$from = "From: {$Name} {$SurName} <blabla@blabla.de>";
$text = "This is my message
         Telefon: {$Telefon}
         Email : {$Email}"

mail($receiver, $subject, $text, $from);

Everything works fine but how can I include my photo? 一切正常,但是如何包含照片?

What I'd suggest is uploading it to a third party image site and sending the link as an image. 我建议将其上传到第三方图像站点,并将链接作为图像发送。 This way you avoid uploading directly to your ftp and makes it easier for any email service to pull the image. 这样,您可以避免直接上传到ftp,并使任何电子邮件服务都更容易提取图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM