从画布上传图片 [英] Image upload from canvas

查看:24
本文介绍了从画布上传图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人请帮助我,这是我第一次在 html 中使用画布,问题是,有没有什么方法可以在表单提交中使用分段文件上传将图像从画布传递到服务器....

Some one please help me, This is the first time i am using canvas in html,and the question is, is there any way to pass the image from canvas into server using multipart file upload in form submission ....

推荐答案

是的,您可以使用 canvas.toDataURL('image/jpeg') 和 ajax 上传画布

yes you can upload your canvas with canvas.toDataURL('image/jpeg') and ajax

$.post('/upload',
{
    uid : uid,
    img : canvas.toDataURL('image/jpeg')
},
function(data) {});

对于分段上传,请访问此问题

for multi-part upload visit this question

使用 FormData 上传 JavaScript Blob

以及将画布转换为 blob 的简单方法

and its easy way for convert canvas to blob

https://blueimp.github.io/JavaScript-Canvas-到 Blob/测试/

这篇关于从画布上传图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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