Dear sir
You are right but, I think Upload button not wrok.
I was test sample text
Could you help me , why upload button not work?
public ContentResult SaveCapture(string data)
{
//string fileName = DateTime.Now.ToString("dd-MM-yy hh-mm-ss");
string fileNametest = DateTime.Now.ToString("deneme");
string datats = "test";
//byte[] imageBytes = Convert.FromBase64String(data.Split(',')[1]);
// string filePath = Server.MapPath(string.Format("~/Captures/{0}.jpg", fileName));
string filePathtest = Server.MapPath(string.Format("~/Captures/{0}.txt", fileNametest));
System.IO.File.WriteAllText(filePathtest, datats);
//System.IO.File.WriteAllBytes(filePath, imageBytes);
return Content("true");
}
But there is no text file again
View is below like sample
@{
Layout = null;
ViewBag.Title = "Kamera Test 1.1";
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<th align="center"><u>Live Camera</u></th>
<th align="center"><u>Captured Picture</u></th>
</tr>
<tr>
<td><div id="webcam"></div></td>
<td><img id="imgCapture" /></td>
</tr>
<tr>
<td align="center">
<input type="button" id="btnCapture" value="Capture" />
</td>
<td align="center">
<input type="button" id="btnUpload" value="Upload" disabled="disabled" />
</td>
</tr>
</table>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="~/Webcam_Plugin/webcam.js"></script>
<script type="text/javascript">
$(function () {
Webcam.set({
width: 320,
height: 240,
image_format: 'jpeg',
jpeg_quality: 90
});
Webcam.attach('#webcam');
$("#btnCapture").click(function () {
Webcam.snap(function (data_uri) {
$("#imgCapture")[0].src = data_uri;
$("#btnUpload").removeAttr("disabled");
});
});
$("#btnUpload").click(function () {
$.ajax({
type: "POST",
url: "/Home/SaveCapture",
data: "{data: '" + $("#imgCapture")[0].src + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) { }
});
});
});
</script>
</body>
</html>
i was test on iphone safari