我已经设法将base64图像转换为blob图像,这很好用我的问题是如何将blob图像发布到php文件并将其插入数据库...这是我的blob图像示例(blob:http %3A //本地主机/ acc6ed62-fa5c-4eaa-951e-9910eb57ad2f); 这是ajax代码::
function Post_Image(){
//This image has a base64 src
var image = $('.img').attr('src');
var contentType = 'image/png';
var b64Data = image.replace(/^data:image\/(png|jpg);base64,/, "");
//converting base64 to blob
var blob = b64toBlob(b64Data, contentType);
//The result from blobUrl= blob:http%3A//localhost/acc6ed62-fa5c-4eaa-951e-9910eb57ad2f
//This url will be posted to the server
var blobUrl = URL.createObjectURL(blob);
var formData = new FormData();
formData.append('userImage', blobUrl);
$.ajax({
url: 'wow.php',
type: 'GET',
data: {userImage:blobUrl},
success:function(data){
}
});
}