2 回答

TA贡献1780条经验 获得超1个赞
谢谢大家的回复。。
我最终首先创建了一个 blob 并发布了 blob。
function dataURLToBlob(dataURL) {
var parts = dataURL.split(';base64,');
var contentType = parts[0].split(":")[1];
var raw = window.atob(parts[1]);
var rawLength = raw.length;
var uInt8Array = new Uint8Array(rawLength);
for (var i = 0; i < rawLength; ++i) {
uInt8Array[i] = raw.charCodeAt(i);
}
return new Blob([uInt8Array], { type: contentType });
$.post("test2.php",
{
name: uInt8Array
},
function(data,status){
alert("Data: " + data + "\nStatus: " + status);
});
}

TA贡献1886条经验 获得超2个赞
data: {
imgBase64: data
//send key is imgBase64 and data value is undefined in given scope
//replace data with dataURL
}
并在 php 文件中将其更改$_POST['image']为$_POST['imgBase64']
添加回答
举报