Save an Image in Sql Server 2005 with Unique Key

Step 1

Take file uploder in .aspx page

Step 2

Wirte code on button click event

        string img = null;
        img = FileUpload1.FileName;
//upload image with help of
        string[] arr = null;
        arr = img.Split('.');
// find the extenson of image
        string ext = arr[arr.Length - 1];
        string uname = DateTime.Now.Ticks.ToString();
//tiks generate 16digit long number using current date and time.
        string uprodimg = uname + "." + ext;
//now join uniquename with extension
        string imgpath = Server.MapPath("~/images/") + "\\" + uprodimg;
//save it images folder using server .mappath  

        FileUpload1.SaveAs(imgpath);