通过电子邮件发送在HTML5画布上创建的图片 [英] Email an image created on HTML5 canvas

查看:160
本文介绍了通过电子邮件发送在HTML5画布上创建的图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个画布,用户可以进行交互以对设计进行更改。现在,在用户完成他的更改后,他可以提交他的设计以及他的电子邮件ID。但要提交设计,我将使用 http://www.nihilogic.dk/ labs / canvas2image /

I have a canvas which user can interact to make changes to design. Now after the user is done with his changes he can submit his design along with his email ID. But to submit the design i am converting the canvas to an image using http://www.nihilogic.dk/labs/canvas2image/

现在我想将此图片与用户的电子邮件ID一起发送。如何直接发送此图片,而不让用户将其保存在其本地系统上。

Now i want to send this image along with user's email ID. How can i send this image directly without letting user save it on his local system.

推荐答案

 if(!empty($_POST['email'])){
    $email=$_POST['email'];
    $image=$_POST['legoImage'];
    $headers="From:".$email."\r\n";
    $headers .= "MIME-Version: 1.0\r\n"; 
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
    list($settings, $encoded_string) = explode(',', $image);
    list($img_type, $encoding_method) = explode(';', substr($settings, 5));

    if($encoding_method == 'base64'){
       $file=fopen("images/newLego.png",'w+');
       fwrite($file,base64_decode($encoded_string)) ;
       fclose($file);
    }
    $my_file = "newLego.png";
    $my_path = "images/";
    $my_subject = "My Design";
    $my_message = "Designed by ".$email;
    mail_attachment($my_file, $my_path, "myemail@gmail.com", $email, $email, $email, $my_subject, $my_message);        
}

我选择了 mail _ attachment()函数此处

I picked up the mail_attachment() function here.

这篇关于通过电子邮件发送在HTML5画布上创建的图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆