i am working on a application where users can capture their photo through webcam. after capturing , data-uri (base64 string) saved in database table. i am binding the data-uri to the image control.and the captured image showing in the image control.
i am using the asp hidden field control in javascript to get the data uri , after click on the capture button, the data-uri value (base64 string) is saving in database table. (image is also showing in the asp image control)
in local machine , it is working fine. (data uri is saving in database table).
but when upload on server, it is not working . after click on capture button, the hidden field value is coming blank. (the hidden field contains the data-uri(base64 string)).
base64string:data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfQAAAFeCAYAAABzUe0CAAAgAElEQVR4XlS9WY+lWXaetyNOnBhzqKyseeyhqieSTYmSKdOWJUgCbfjCF7YF+BcZ9oVlg5BpyxQMkWqRIiTbIgTSgAATkKAby7IsDi2JbLJpqtnNrq7qqqwcYjwnIvw+z7u/LDqrozPjnG/Ye+211rumvfbOL/7d//H29nYzdnZuxhi7Y+d2Z4yb23
how to get the hidden field value on button click ? or how to assign the hidden field value in session object in javascript. so that i can get the data-uri from the session object.
please help ..
What I have tried:
<asp:HiddenField ID="hdnVal" runat="server" EnableViewState="true" />
<script type="text/javascript" src="css/webcam.min.js"></script>
<!-- Configure a few settings and attach camera -->
<script language="JavaScript" type="text/javascript" >
Webcam.set({
width: 320,
height: 240,
dest_width: 500,
dest_height: 350,
image_format: 'png',
jpeg_quality: 90
});
Webcam.attach('#my_camera');
function take_snapshot() {
var val = document.getElementById('<%=hdnVal.ClientID %>');
Webcam.snap(function (data_uri) {
var data = data_uri.toString();
val.value = data_uri.toString();
alert(val.value.toString());
document.getElementById('<%=hdnVal.ClientID %>').innerText = data_uri;
});
}
</script>
Capture Button click event code :
img.ImageUrl = hdnVal.Value.ToString()
img.Visible = True
Try
con.Open()
Dim cmd As New SqlCommand()
cmd.CommandText = "spAddImages"
cmd.CommandType = Data.CommandType.StoredProcedure
cmd.Connection = con
cmd.Parameters.Add("@val", Data.SqlDbType.NVarChar).Value = hdnVal.Value.ToString()
cmd.ExecuteNonQuery()
con.Close()
Catch ex As Exception
End Try