将“canvas”图像数据上传到服务器 [英] Uploading 'canvas' image data to the server

查看:329
本文介绍了将“canvas”图像数据上传到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将画布图像数据即时上传到服务器(数据库),即,我需要创建一个表单和一个input =文件,并发布图像数据,而无需任何用户交互。

I need to upload the canvas image data to the server (database) on the fly, i.e., I need to create a form and with an input=file, and post the image data without any user interaction.

推荐答案

您不需要文件输入,只需获取 ctx.getImageData()并使用Ajax发布到服务器。

You don't need a file input, just get the data with ctx.getImageData() and post it to the server with Ajax.

请参阅 MDN文档 CanvasRenderingContext2D.getImageData()

但是你不会能够在IE中获取图像数据,即使使用 ExCanvas

But you won't be able to get the image data in IE, even with ExCanvas.

这篇关于将“canvas”图像数据上传到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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