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 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答