Reputation: 171
I have one save button which will save the image in the desktop from camera when button is click below is the code.....
<input id="Save" style="Z-INDEX: 1; LEFT: 8px; WIDTH: 128px; TOP: 36px; HEIGHT: 24px"
onclick="return save_onclick()" type="button" value="Save Image" name="save">
function save_onclick()
{
document.AxuEyeCam.SaveImage("test.jpg");
}
It not good to save image in one pc because the image will not be available worldwide, it will be available for only to the pc which has image.
what i think is to save image in web application using mappath or store image in sql server or may be in cloud so that image will be available worldwide.
Can anybody suggest me how this is possible.
Thanks a lot
Upvotes: 1
Views: 1750
Reputation: 104
Here is the Steps
1- Create a web service and host it in a server ( the web service will contain a web method to upload your file and save it to a server)
2- Call the web service from your application ( Desktop application or web application )
Here is a Good Example for the web service and the client application
I don't recommend saving the image as binary in the database because you may find it harder to retrieve and display
I do recommend saving the file name in the sql server table and save the image itself to a separate folder in your server
Upvotes: 2
Reputation: 3047
Currently you are using javascript to save the image, what control are you using to store the image? i.e. what is the AxeEyeCam control you have?
If you can access this control from the Server-Side code then you should be able to read the image into a byte array and save this into SQL.
The following code uses a FileUpload
control to read the data into a byte array
byte[] bArray = new byte[fileUpImage.FileBytes().Length + 1];
int iBytesRead = fileUpImage.FileContent().Read(bArray, 0, fileUpImage.FileBytes().Length);
The following code then inserts this into a SQL table called TABLE
:
try {
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(localConString);
conn.Open();
string insertStatement = "Insert Into [TABLE] ([IMAGE COLUMN]) VALUES (@Image)";
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(insertStatement, conn);
cmd.Parameters.Add("@Image", System.Data.SqlDbType.Image);
cmd.Parameters["@Image"].Value = bArray;
double rdr = cmd.ExecuteNonQuery();
conn.Close();
} catch (Exception ex) {
//Catches an error if one occurs
} finally {
if (conn != null) {
NewConn.Close();
}
}
Upvotes: 0