{
bitmap img = new bitmap(fileupload1.posted file .filename);
grapics grp = grapics.fromimage(img);
grp.smoothingmode=smoothingmode.AntiAlias;
grp.drawstring("dani web")new font ("verdananna",20),systembrush.windowtext,2,2);
Response.contentType="image/jpeg";
img.save(Response.Ouyputstream,img.Raw Format));
}

By using the above coding i have insert the text to image , but i don't know how to upload that
text contain image to database, i want to save that image as a binary in database ,,,

reply as soon as possible ..

That's the problem, you're doing it the wrong way. You cannot apply the watermark to the image and upload it to the server without saving it first.

Just save the image, then upload the image with the new path to the database, then delete the image.

What you have just done was add the watermark at runtime, therefore, you have added it when the image is being sent to the client. It was never added before you sent anything to the database. That is why you must save the image first, add the watermark, upload the image, delete the image from the folder, and you're done. It's an extra 3 lines of code.

img.SaveAs(whaterver)

openthe image
apply the watermark,
save it

Upload it to the server as a binary

if file.exists(the path to image) then file.delete(path to image)

That's the problem, you're doing it the wrong way. You cannot apply the watermark to the image and upload it to the server without saving it first.

Just save the image, then upload the image with the new path to the database, then delete the image.

What you have just done was add the watermark at runtime, therefore, you have added it when the image is being sent to the client. It was never added before you sent anything to the database. That is why you must save the image first, add the watermark, upload the image, delete the image from the folder, and you're done. It's an extra 3 lines of code.

img.SaveAs(whaterver)

openthe image
apply the watermark,
save it

Upload it to the server as a binary

if file.exists(the path to image) then file.delete(path to image)

ok...how can i save it and whr i save it???
img.SaveAs(whaterver)

plz explaine briefly !!!!!!!!!!

follow the code you have above. Instead of saving it to the output stream, save it to a folder you specify on your server.

Actually... try saving it directly. it might work since you created a new image from that image uploaded.

Dim SQL As String = "INSERT INTO images VALUES (@img, @txt)"

Dim sqlcommand As New SqlCommand(SQL, connection string)
sqlcommand.Parameters.AddWithValue("@img", img)
sqlcommand.Parameters.AddWithValue("@txt", "some text")

sqlcommand.ExecuteNonQuery()
This article has been dead for over six months. Start a new discussion instead.