我有一个显示为 blob 的图像:
<img id="imgcaptmobile" width="487" src="blob:http%3A//www.mysite.com/ab750f54-ecb4-4dc9-8d9d-4e28c4a41262">
请问如何使用jquery ajax将图片上传为文件?...
我有一个显示为 blob 的图像:
<img id="imgcaptmobile" width="487" src="blob:http%3A//www.mysite.com/ab750f54-ecb4-4dc9-8d9d-4e28c4a41262">
请问如何使用jquery ajax将图片上传为文件?...
尝试这个
var blobURL = "blob:http%3A//www.mysite.com/ab750f54-ecb4-4dc9-8d9d-4e28c4a41262";
var image = new Image();
image.onload = function() {
var canvas = document.createElement('canvas');
var ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0, image.width, image.height);
var picture = canvas.toDataURL("image/jpeg", 1.0);
var data = new FormData();
data.append("picture", picture);
$.ajax({
"url": "The Upload URL",
contentType: false,
processData: false,
type: 'POST',
"data": data,
success: function(response) {
//handle the response
}
});
}
image.src = blobURL;
<img src='blob:http%3A//www.mysite.com/ab750f54-ecb4-4dc9-8d9d-4e28c4a41262' />