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

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

问题描述

我需要将画布图像数据即时上传到服务器(数据库),即我需要创建一个表单并使用 input=file,并在没有任何用户交互的情况下发布图像数据.

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() 获取数据并用阿贾克斯.

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

请参阅 CanvasRenderingContext2D.getImageData 的 MDN 文档().

但是您将无法在 IE 中获取图像数据,即使使用 ExCanvas.

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

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

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