score:0
Accepted answer
//This is your .aspx code. The AllowMultiple on FileUpload only works in .NET Framework 4.5+
<form id="form1" runat="server" enctype="multipart/form-data">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:FileUpload ID="FileUpload1" runat="server" AllowMultiple="true" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="Button1" />
</Triggers>
</asp:UpdatePanel>
</div>
</form>
//This is your code behind
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFiles)
{
foreach (var file in FileUpload1.PostedFiles)
{
string value = Guid.NewGuid().ToString();
string extension = new FileInfo(file.FileName).Extension;
string path = Server.MapPath("~/pimg/" + value + extension);
string virtualPath = "/pimg/" + value + extension;
System.Drawing.Image img = System.Drawing.Image.FromStream(file.InputStream);
img.Save(path);
if (Request.Cookies["aa"] == null)
{
Response.Cookies["aa"].Value = virtualPath;
}
else
{
Response.Cookies["aa"].Value = Request.Cookies["aa"].Value + "|" + virtualPath;
}
}
}
if (Request.Cookies["aa"] != null)
{
string[] picArray = Convert.ToString(Request.Cookies["aa"].Value).Split('|');
foreach (var item in picArray)
{
Image img = new Image();
img.ImageUrl = item.ToString();
img.Height = 150;
img.Width = 100;
UpdatePanel1.ContentTemplateContainer.Controls.Add(img);
}
}
}
Source: stackoverflow.com
Related Query
- upload multiple images and display them
- Group join with multiple conditions and one of them being with a constant
- LINQ - Combine multiple lists to form a new list and align them by key?
- How to return values from a LINQ query and display them in a table using C#, ASP.NET MVC and Entity Framework
- Adding multiple values in ViewModel and show them in a view
- How to split string by delimeter and multiple group by and count them in Linq?
- Linq group by multiple columns and sum them together
- How to select multiple columns with entity framework and display it with textBlocks?
- Join/merge two excel files in asp.net and display them in gridview
- C# XDocument get all images from XML and show them in LongListSelector
- select multiple columns using linq and sum them up
- How to use multiple 'Where' expressions and chain them together with AND and OR using C#/.NET?
- How to use Linq To XML to get multiple elements and store them differently?
- EF LINQ include multiple and nested entities
- Select multiple fields group by and sum
- Creating N objects and adding them to a list
- lambda expression join multiple tables with select and where clause
- LINQ- Combine Multiple List<T> and order by a value (.Net 3.5)
- Using LINQ to group by multiple properties and sum
- Selecting multiple columns with linq query and lambda expression
- When using LINQ, what is the difference between && and multiple where clauses?
- Multiple group by and Sum LINQ
- anonymous type and multiple properties
- Joining multiple where clauses in LINQ as OR instead of AND
- LINQ: differences between single Where with multiple conditions and consecutive Wheres with single condition
- How do I remove items from generic list, based on multiple conditions and using linq
- LINQ Join with multiple AND conditions
- Access all of the data after joining two tables and group them using linq
- LINQ to SQL - How to efficiently do either an AND or an OR search for multiple criteria
- What's the difference between multiple where clauses and && operator in LINQ-to-SQL?
More Query from same tag
- C# linq expression. How to get different offsets and 'any' offset?
- LINQ query AND & OR
- Getting all record by using a reference number in LINQ
- How to concat expression in linq query
- C# / .NET comparing two large lists and finding missing items from both list
- LINQ-to-Entities WHERE condition not executed on sql server
- LINQ A List inside a join query
- linq query data not showing error
- Using LINQ Expression Instead of NHIbernate.Criterion
- linq to sql Association problem with foreign keys
- Is it necessary use thread-safe methods when i use AsParallel?
- XML LINQ statement almost giving desired results
- How to place an If/Else statement in a where clause in a linq query?
- linq how to build a where predicate
- how write viewmodel to show 2 tables in one view and join between they
- Merging lists in another list using LINQ c#
- How to Return Thread result
- How to remove spaces from a column in a list using Linq?
- Get list of list with same complex objects
- Is there a way I could filter values using the Model class?
- Iterate over 2 nested lists
- Cannot retrieve object from inner dictionaries/lists
- LINQ SUM data based on Array Results
- Ignore read-only class properties when using DataContext.ExecuteQuery<T>
- How to save subquery result?
- IQueryable doesn't allow ThenBy
- 'Specified cast is not valid' in LAMBDA expression when querying float field
- MVC Search Functionality Implementation
- Get an acronym from a string in C# using LINQ?
- Asp.net MVC4: Custom paging