dongtu1789 2011-11-02 20:38
浏览 28

将canvas标记的内容传输到php脚本[duplicate]

Possible Duplicate:
Sending images from Canvas elements using Ajax and PHP $_FILES

I created an application where users can edit in real time the content of a canvas tag. It then retrieves the contents of the tag like this:

var canvas = document.getElementById("canvas");
var imgca  = canvas.toDataURL("image/png");

Now I am looking for a way to pass the contents of the imgca variable to a PHP script that the user can then be sent by e-mail.

Does anyone has any idea?

  • 写回答

1条回答 默认 最新

  • dongzhuo1930 2011-11-02 20:54
    关注

    You could try having a form with a hidden input element that posts to a php script and use your imgca to set the value of this hidden input element, so something likes this:

    var canvas = document.getElementById("canvas");
    var imgca  = canvas.toDataURL("image/png");
    
    document.getElementById("hiddenElement").value = imgca;
    document.getElementById("myHiddenForm").submit();
    

    with html:

    <form id="myHiddenForm" action="somescript.php" method="post" style="display:none;">
        <input type="hidden" id="hiddenElement" value="" />
    </form>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统