从输入类型为“的照相机捕获上载图片时出现问题”;文件";捕获=";照相机“;使用JQM->;Ajax->;Asp.net[WebMethod]
从摄像头捕获上传图片时出现问题从输入类型为“的照相机捕获上载图片时出现问题”;文件";捕获=";照相机“;使用JQM->;Ajax->;Asp.net[WebMethod],asp.net,ajax,html,file-upload,xmlhttprequest,Asp.net,Ajax,Html,File Upload,Xmlhttprequest,从摄像头捕获上传图片时出现问题 $('#uploadpicture').click(function() { var fd = new FormData(); fd.append('photo', $('#filefromcam')[0].files[0]); $.ajax({ url: "Butikk.aspx/UploadPicture", type: "POST", da
$('#uploadpicture').click(function() {
var fd = new FormData();
fd.append('photo', $('#filefromcam')[0].files[0]);
$.ajax({
url: "Butikk.aspx/UploadPicture",
type: "POST",
data: fd,
processData: false, // tell jQuery not to process the data
contentType: false, // tell jQuery not to set contentType
success: function (data) {
var result = data.d;
console.log(data.d);
},
error: function (xhr, errorType, exception) { //Triggered if an error communicating with server
var errorMessage = exception || xhr.statusText;
alert("Feilmelding: " + errorMessage);
}
});
});
<td>
<input type="file" id="filefromcam" capture="camera" accept="image/*" data-mini="true">
</td>
<td>
<a data-role="button" id="uploadpicture" data-mini="true">Last opp</a>
</td>
<form id="form" runat="server" enctype="multipart/form-data">
[WebMethod]
public static void UploadPicture(object fd)
{
var test = "test"; // just to see if debug mode occurs for breakpoint.
}
var file = input.files[0];
var form = new FormData();
xhr = new XMLHttpRequest();
form.append('image', file);
xhr.open('post', 'TestTest(dot)aspx/UploadPicture', true);
xhr.send(form);