Bhavesh Vankar

Bhavesh Vankar

  • 755
  • 1.2k
  • 89.4k

store image into binary format which is captured by webcam

Dec 21 2020 12:25 PM
how to convert image into binary format and store it into binary format in sql server. image is captured by webcam and retrive from another page on image control. i want to convert into binary and want to store that image into sql server database in binary format. 
also need if image control is blank image control should be validate.
 
below is my code to convert image into binary.
 
  1. var WebClient = new WebClient();  
  2.                     byte[] imgbytes = WebClient.DownloadData(image);  
  3.                     MemoryStream ms = new MemoryStream();  
  4.                     byte[] imgtobinary = new byte[ms.Length];  
  5.                     ms.Position = 0;  
  6.                     ms.Read(imgtobinary, 0, (int)ms.Length);  
image control validation code.
  1. if (!string.IsNullOrEmpty(image))  
  2. {  
  3. }
 when first time record saved and press save button again validation occured but record being save continue the validation not working properly. 
can anyone help me...? 

Answers (2)