通过电子邮件发送在 HTML5 画布上创建的图像
我有一个画布,用户可以通过交互来更改设计。现在,用户完成更改后,可以提交他的设计及其电子邮件 ID。但为了提交设计,我使用 http://www.nihilogic.dk/ 将画布转换为图像labs/canvas2image/
现在我想将此图像与用户的电子邮件 ID 一起发送。我如何直接发送此图像而不让用户将其保存在本地系统上。
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/
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为您需要一些 javascript 魔法,并且因为您已经使用 HTML5 canvas,所以这应该不是问题。
因此,提交按钮上的 onclick 事件将向您的后端 php 邮件程序脚本发出 ajax 请求。
您只需将 strDataURI 作为参数传递即可。
现在,我认为您还应该将这些保存在数据库中,以便电子邮件可以在其中包含此图像标签:
并且generate_image.php脚本将执行类似这样的操作
I'm thinking you need some javascript magic, and because you already use HTML5 canvas, that shouldn't be a problem.
So, an onclick event on the submit button that will make an ajax request to your backend php mailer script.
You just have to pass the strDataURI as a parameter.
Now, I think you should also save these in your database, so that the email can just contain this image tag inside:
And that the generate_image.php script will do something like this
我选择了
mail_
attachment() 函数 这里。I picked up the
mail_
attachment() function here.假设您已经使用您发布的教程成功创建了画布的图像文件,您可以使用 PEAR 之类的库 Mail_Mime 将附件添加到您的电子邮件中。
您可以参考此问题获取使用 Mail_Mime 的示例。
Assuming you've succeeded in creating an image file of your canvas using the tutorial you posted, you can use a library like PEAR's Mail_Mime to add attachments to your email.
You can refer to this question for an example using Mail_Mime.