jSignature图片导出到PHP电子邮件 [英] jSignature image export to PHP email

查看:131
本文介绍了jSignature图片导出到PHP电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有关jSignature的帮助.我能够创建一个图像,然后将该图像写回到页面中.我无法工作的原因(以及我首先探索此插件的原因)是将图像导出到页面外.我想获取图像数据并通过电子邮件发送出去,以便图像显示在电子邮件正文中.如果尝试了很多方法而没有任何效果.目前,我的js如下所示:

I need help with jSignature. I am able to create an image and then write that image back into the page. What I can't get working (and the reason I was exploring this plugin in the first place) is the exporting of the image out of the page. I want to take the image data and send it out in an email so that the image shows up in the body of the email. If have tried a lot of approaches and nothing has worked. Currently my js looks like this:

var $sigDiv = $("#signature").jSignature();
      $('<input type="button" value="Reset">').bind('click', function(e){
        $sigDiv.jSignature('reset');
      }).appendTo($sigDiv);

提交表格后,它看起来像这样:

And upon submit of the form it looks like this:

var datapair = $sigDiv.jSignature("getData", "svg");
      var i = new Image();
      i.src = "data:" + datapair[0] + "," + datapair[1];
      $(i).appendTo($("#success"));

我尝试获取一个变量中的图像数据,并通过AJAX将其以数据字符串的形式发送到PHP邮件处理表单中,如下所示:

I try to grab that image data in a variable and through AJAX send it in a data string to a PHP mail processing form doing something like this:

<img src="<?php echo $_POST['signature']; ?>"/>

或者这个:

<object src="<?php echo $_POST['signature']; ?>"></object>

我已经精疲力尽了,要设法使它显示出出现在电子邮件中的图像.非常感谢您的帮助.

I've exhausted myself on trying to get this to display an image in the email that goes out. Any help is much appreciated.

推荐答案

YEHESSS!得到它的工作.如果我导出为图像,并在图像上进行encodingURIComponent(image),则AJAX调用不会破坏图像数据.现在像BEAST一样工作.谢谢您的帮助,阿比德.

YEHESSS! Got it to work. If I export as an image and do encodeURIComponent(image) on the image the AJAX call doesn't screw up the image data. Works like a BEAST now. Hey thanks for your help Abid.

这篇关于jSignature图片导出到PHP电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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