i must convert my uploaded images in base 64 to and from a sql table... my codes are as follow:
protected void ddlImage_SelectedIndexChanged(object sender, EventArgs e) { string selectedValue = ddlImage.SelectedItem.Value; ShowImages(txtEmail.Text); }
private void ShowImages(string email) { string[] images = Directory.GetFiles(Server.MapPath("~/images/customers/" + email)); ArrayList imageList = new ArrayList(); foreach (string image in images) { string imageName = image.Substring(image.LastIndexOf(@"\") + 1); imageList.Add(imageName); } ddlImage.DataSource = imageList; ddlImage.DataBind(); }
protected void btnuploadimage_Click(object sender, EventArgs e) { try { string folder = Server.MapPath("~/images/customers/" + txtEmail.Text); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } string filename = Path.GetFileName(FileUpload1.FileName); FileUpload1.SaveAs(Server.MapPath("~/images/customers/" + txtEmail.Text + "/" + filename)); lblImage.Text = "image " + FileUpload1.FileName.ToString() + " successfully uploaded!"; Image1.ImageUrl = "~/images/customers/" + txtEmail.Text + "/" + filename; } catch (Exception) { lblImage.Text = "uppload Failed!"; } }
how i should put the encoded image to sql table and how i should decode it from sql table and put in Image1.ImageUrl??!! appreciate your respond, more grateful if you give me the codes. kind regards