如何将动态生成的图像保存到我的数据库? [英] How can I save a dynamically generated image to my database?

查看:89
本文介绍了如何将动态生成的图像保存到我的数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HTML页面,可以将用户的签名捕获为SVG。我在页面上将它转换为.png并将其放到图像容器中。

我如何利用它进入数据库?我知道如何使用:< input type =file/> 但我不知道如何传递<



这会将我的SVG更改为PNG



pre> $(#save)。click(function(){
var datapair = sigdiv.jSignature(getData,svg);
var i = new Image();
i.src =data:+ datapair [0] +,+ datapair [1];
$(i).appendTo($(#outputSvg ));

var canvas = document.getElementById(canvas);

canvg(canvas,datapair [1]);

var img = canvas.toDataURL(image / png);
$(#outputRaster)。append(< img src ='+ img +'/>);
});

如何取< img /> tag我在< div id ='outputRaster'> >中生成并传递给我的PHP?我知道如何将它放入数据库,它实际上只是将图像从我的视图图层获取到我的PHP页面,该页面仅用于数据访问。



任何帮助或建议都将不胜感激! 保存图像作为文件。
将文件路径存储在数据库中。



Léon


I have an HTML page that captures a user's signature as an SVG. I convert it on the page to a .png and put it into an image container.

How can I utilize this to go into a database? I know how to do it using: <input type="file" /> but I have no clue how I would pass an <img /> element to PHP.

This changes my SVG to a PNG

       $("#save").click(function(){
          var datapair = sigdiv.jSignature("getData", "svg");
          var i = new Image();
          i.src = "data:" + datapair[0] + "," + datapair[1];
          $(i).appendTo($("#outputSvg"));

          var canvas = document.getElementById("canvas");

          canvg(canvas, datapair[1]);

          var img = canvas.toDataURL("image/png");
          $("#outputRaster").append("<img src='"+img+"'/>");
        });

How do I take the <img /> tag I am generating in <div id='outputRaster'> and pass it to my PHP? I know how to put it into the database, it's really just getting the image from my view layer to my PHP page, which is only being used for data access.

Any help or advice would be greatly appreciated!

解决方案

Save the image as a file. Store the file path in your database.

Léon

这篇关于如何将动态生成的图像保存到我的数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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