multiple files upload in asp.net and asp.net

Posted by Nadh123 under ASP.NET on 2/8/2013 | Points: 10 | Views : 1566 | Status : [Member] | Replies : 4
multiple files upload in asp.net and asp.net

Mahendra
91-9908699686



Responses

Posted by: Kusumas on: 2/8/2013 [Member] Starter | Points: 25

Up
0
Down
<asp:FileUpload ID="FileUpload1" runat="server" /><br />
<asp:FileUpload ID="FileUpload2" runat="server" /><br />
<asp:FileUpload ID="FileUpload3" runat="server" /><br />
<asp:FileUpload ID="FileUpload4" runat="server" /><br />

Submit Here:<asp:Button ID="btnUpload" runat="server" Text="Upload Multiple Files" OnClick="UploadMultipleFiles" />


C#:
protected void UploadMultipleFiles(object sender, EventArgs e)
{
HttpFileCollection files = Request.Files;
for (int i = 0; i < files.Count; i++)
{
HttpPostedFile file = files[i];
string path = Server.MapPath("~/");
string fileName = file.FileName;
file.SaveAs(path + fileName);
Response.Write(fileName + " uploaded successfully ! <br />");
}
}




Nadh123, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Self-Innovator on: 2/8/2013 [Member] Bronze | Points: 25

Up
0
Down
<table cellpadding="8" cellspacing="3"  >

<tr>
<td colspan=2>

</td>
</tr>
<tr>
<td>
Banner :
</td>
<td>
<asp:FileUpload ID="bannerUpload" runat="server" />
<asp:Image ID="imgBanner" runat="server" ImageUrl=<%#Bind("bannerimage") %> Width="75%"/>



</td>
</tr>

<tr>
<td>
Link :
</td>
<td>
<asp:TextBox ID="txtLink" runat="server" Width="300"></asp:TextBox>
</td>
</tr>

<tr>
<td>
<asp:ValidationSummary ID="ValidationSummary1" runat="server"
ShowMessageBox="True" ShowSummary="False" ValidationGroup="v1" />
</td>
<td>

<asp:Button ID="btnAdd" runat="server" Text="Add" Class="mybutton"
ValidationGroup="v1" Font-Bold="True"
Width="84px" onclick="btnAdd_Click" />
</td>
</tr>
</table>

protected void btnAdd_Click(object sender, EventArgs e)
{
matrimony m = new matrimony();
MessageBox msg = new MessageBox();
string bannerimages = string.Empty;
string bannerlink = txtLink.Text;

string uniquename = (DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString());

if (bannerUpload.PostedFile.ContentLength > 0)
{
string flag = Path.GetExtension(bannerUpload.PostedFile.FileName);
if (flag == ".jpeg" || flag == ".JPEG" || flag == ".jpg" || flag == ".JPG" || flag == ".png" || flag == ".PNG" || flag == ".bmp" || flag == ".BMP" || flag == ".gif" || flag == ".GIF" || flag == ".wmf" || flag == ".WMF")
{
string flag1;
string flag2 = Server.MapPath("~\\uploads") + "\\";
string flag3 = Path.GetFileName(bannerUpload.PostedFile.FileName);
string[] words = flag3.Split('.');
flag1 = flag2 + uniquename + flag3;
bannerUpload.PostedFile.SaveAs(flag1);
string url = "~\\" + "uploads" + "\\" + uniquename + flag3;
bannerimages = url.Replace("\\", "/");
m.addbannerimages(bannerimages, bannerlink);
msg.Show("Banner image added successfully");
}
else
{
msg.Show("Only image file allowed");

}
}
else
{
msg.Show("Image file required");
}
}



Join Hands Change lives
Thanks & Regards
Straight Edge Society

Nadh123, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nadh123 on: 2/8/2013 [Member] Starter | Points: 25

Up
0
Down
using only one fileupload control and upload a multiple files ata time

Mahendra
91-9908699686

Nadh123, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Satyapriyanayak on: 2/11/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Refer
http://imar.spaanjaars.com/567/uploading-multiple-files-at-once-using-aspnet-45
http://www.dotnetcurry.com/ShowArticle.aspx?ID=68
http://www.codeproject.com/Articles/15742/Multiple-File-Upload-With-Progress-Bar-Using-Flash
http://www.dotnetfunda.com/articles/article981-multiple-files-upload-in-aspnet-and-aspnet-with-jquery.aspx
http://www.dotnetjalps.com/2012/07/Multiple-file-upload-with-asp-net-4-5-and-Visual-Studio-2012.html
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/AjaxFileUpload/AjaxFileUpload.aspx
http://tutorialtub.com/info/adding-file-upload-fields-dynamically-to-an-html-page-using-javascript

If this post helps you mark it as answer
Thanks

Nadh123, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response