我在jQuery Webcam遇到了挑战。我想保存ASP.Net Core 2中控制器类中停止调用的方法。
jQuery Webcam.Save方法不会在控制器类中调用该方法。下面是我的jQuery和C#代码:
$("#camera").webcam({
"width": 320,
"height": 240,
"mode": "save",
"swffile": "@Url.Content("~/js/jscam.swf ")",
"onTick": function() {},
"onSave": function() {
UploadPic();
},
"onCapture": function() {
webcam.save("@Url.Action("Capture", "User")");
},
"debug": function(status, string) {
$("#cameraStatus").html(status + ": " + string);
},
"onLoad": function() {
$("#cameraList").empty();
var cameraListVar = webcam.getCameraList();
for (var i in cameraListVar) {
$("#cameraList").append("<option>" + cameraListVar[i] + "</option>");
}
}
});
public void Capture()
{
DeleteImage();
Request.EnableRewind();
var stream = Request.Body; //.InputStream;
string dump;
using(var reader = new StreamReader(stream, Encoding.UTF8, true, 1024, true))
{
dump = reader.ReadToEnd();
}
Request.Body.Position = 0;
string date = DateTime.Now.ToString("yyyymmddMMss");
path = Path.Combine(env.WebRootPath, "images/webcam/" + date + "userPicture.Tiff");
pathHistory += path + ";";
WriteAllBytes(path, String_To_Bytes2(dump));
TempData["userPicture"] = "/images/webcam/" + date + "userPicture.Tiff";
}
由于
答案 0 :(得分:0)
我已经解决了。它被AntiForgeryToken阻挡。