i wont to upload malty images from FileUpload store theme in cookies and display the images in an update penal in the same time i get only the last photo updated to the update anal
and this the code behind in C# :
protected void addphoto_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile )
{
for (int i = 0; i < FileUpload1.PostedFiles.Count; i++)
{
string vale = Guid.NewGuid().ToString() + ".png";
string path = Server.MapPath("").Replace("user", "pimg") + "\\" + vale;
FileUpload1.SaveAs(path);
b = "~/pimg/" + vale;
//string test = "~/pimg/d13526f4-9713-48fa-bb5d-a37f27b0366e.png";
if (Request.Cookies["aa"] == null)
{
Response.Cookies["aa"].Value = b;
}
else
{
Response.Cookies["aa"].Value = Request.Cookies["aa"].Value + "|" + b;
}
}
}
if (Request.Cookies["aa"] != null)
{
s = Convert.ToString(Request.Cookies["aa"].Value);
string[] strarr = s.Split('|');
foreach (var item in strarr)
{
//string html = "<a class='btn btn-primary' style='padding: 10px; margin: 10px' href='deletitem?myid=" + item.ProdectID + "'>" + item.Name + "</a>" + "";
Image img = new Image();
img.ImageUrl = item.ToString();
img.Height = 150;
img.Width = 100;
UpdatePanel2.ContentTemplateContainer.Controls.Add(img);
}
}
}
Aucun commentaire:
Enregistrer un commentaire