I have an image on a page, e.g <img id="img3" runat="server" src="image.jpg" width="200" height="200"/>
and I'd like to save the image referenced by the src
attribute in my database using stored procedure.
I should convert the image to binary first. Here is what I have so far:
Stream fs = FileUpload1.PostedFile.InputStream;
BinaryReader br = new BinaryReader(fs);
Byte[] bytes = br.ReadBytes((Int32)fs.Length);
cmd.Parameters.AddWithValue("@img", byte);
But the thing is that I don't want to save the uploaded image FileUpload1.PostedFile.InputStream
, I want to save the image that I had its src
.
Is there a way to put the image src
in stream so that I can save it or what is the right way for doing that?