0

I am using SQL Database,
In my example of my webpage, i got FileUpload & Image & Button Controls.
i wanna to know any tutorials or tricks from code behind that able to
upload the image file into my sql database and how to display the image in my Image controls?
P/S: For profile picture purpose

Edited by gahhon

2
Contributors
5
Replies
21
Views
4 Years
Discussion Span
Last Post by gahhon
1

I think you may want to take this and resolve it in parts. For example, first clarify if you are planning to save the image in the database, or on the file system and the link in the database?

I've looked through my documentation and found a bookmark that I used quite a bit of time ago. I think it covers pretty much what you are asking for. take a look.

Save and Retrieve Images from the Database

Edited by JorgeM

0

now i am able to upload and display already.
But how can i self upload a image to database?

0
Image img = new Image();
img.ImageUrl = "~/images/samples.png";

from code behind, how to insert to database?

0
        protected void uploadImage()
        {
            string strPhoto = AppDomain.CurrentDomain.BaseDirectory + "/images/Blank.png";
            FileStream fsPhoto = new FileStream(strPhoto, FileMode.Open, FileAccess.Read);
            Byte[] imageByte = new Byte[fsPhoto.Length];
            fsPhoto.Read(imageByte, 0, Convert.ToInt32(fsPhoto.Length));

            // SQL CODE
        }

Problem solved. Thanks

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.