在c#中将画布数据作为图像发送到服务器 [英] Sending canvas data as a image to server in c#

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

问题描述





我正在尝试使用以下功能将画布图像发送到服务器,但功能无法执行此操作。我没有收到错误的地方,请帮忙...



Hi ,

I am trying to send canvas image to server using following function, but function is unable to do so. I am not getting where error occurred ,Please help...

function UploadPic() {
        // Generate the image data
        var Pic = document.getElementById('cnvEdit').toDataURL("image/png");
        Pic = Pic.replace(/^data:image\/(png|jpg);base64,/, "");
        // Sending the image data to Server
        $.ajax({
            type: 'POST',
            url: 'Save_Picture.aspx/UploadPic',
            data: '{ "imageData" : "' + Pic + '" }',
            contentType: 'application/json; charset=utf-8',
            dataType: 'json',
            success: function (msg) {
                alert('Done, Picture Uploaded.');
            }
        });
    }

推荐答案

.ajax({
type:' POST'
url:' Save_Picture.aspx / UploadPic'
data:' {imageData: ' + Pic + ' }'
contentType:' application / json; charset = utf-8'
dataType:' json'
成功: function (msg){
alert(' 完成,上传图片。');
}
});
}
.ajax({ type: 'POST', url: 'Save_Picture.aspx/UploadPic', data: '{ "imageData" : "' + Pic + '" }', contentType: 'application/json; charset=utf-8', dataType: 'json', success: function (msg) { alert('Done, Picture Uploaded.'); } }); }


您可以使用方法 canvas.toDataURL(type,jpegquality)

http:// msdn。 microsoft.com/en-us/library/ie/ff975241%28v=vs.85%29.aspx [ ^ ]。



祝你好运,

-SA
You can use the method canvas.toDataURL(type, jpegquality):
http://msdn.microsoft.com/en-us/library/ie/ff975241%28v=vs.85%29.aspx[^].

Good luck,
—SA


这篇关于在c#中将画布数据作为图像发送到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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