好的,我可以用手机的相机拍照并在 img 中查看,现在我想通过收到
的网络服务上传它<File> base64Binary </File>.
这是我设置图像的方式:
function onPhotoDataSuccess(imageData)
{
var smallImage = document.getElementById('smallImage');
smallImage.style.display = 'block';
smallImage.src = "data:image/jpeg;base64," + imageData;
}
这就是我尝试发送它的方式:
var ima=document.getElementById("smallImage").src;
var soapRequest ='<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema- instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'+
'<soap:Body>'+
'<InsertFileInfo xmlns="http://tempuri.org/">'+
'<File>'+ima+'</File>'+
'<FileName>sldkq.jpg</FileName>'+
'<Description>Photo</Description>'+
'<Code>'+CodeFile+'</Code>'+
'</InsertFileInfo>'+
'</soap:Body>'+
'</soap:Envelope>';
$.ajax({
type: "POST",
url: wsUrl,
contentType: "text/xml",
dataType: "xml",
data: soapRequest,
success: processSuccess,
error: processError
});
function processSuccess(data, status, req)
{
if (status == "success")
{
alert("sent");
}
}
function processError(data, status, req)
{
alert('error'+data.state);
//alert(req.responseText + " " + status);
}
然后几分钟过去了,我终于得到了processError函数消息。
有人可以告诉我这有什么问题吗?
答案 0 :(得分:0)
我必须解决它。如果有人有这个问题:变量&#39; ima&#39;请求.src的img但是没有用。所以我使用了其他东西来存储图片的base64值:
window.localStorage.setItem("CodePhoto", imageData);
我在请求中读到了这样的内容:
var codePhoto = window.localStorage.getItem("CodigoFoto");
最后把它放在
中 <File></File>
像这样:
...'<File>'+codePhoto+'</File>'+...