0
Posted on 6:30 AM by Softminer and filed under

<%@ Page Language="C#" Debug="true"%>

<script runat="server">

void Button1_Click(object Source, EventArgs e)

{

txtMsg.InnerHtml = saveFiles();

}


string saveFiles() {

string strMessage = "";

string strFileName;

HttpPostedFile objFile;

for (int i=0; i

objFile = Request.Files[i];

if (objFile.FileName != "") {

strFileName = objFile.FileName;

strFileName = strFileName.Substring(strFileName.LastIndexOf("\\")+1);

try {

objFile.SaveAs("c:\\upload\\"+strFileName);

strMessage+= "Uploaded: c:\\upload\\"+strFileName+"
"
;

}

catch (Exception err) {

strMessage+= "Failed uploading "+strFileName+": "+err.ToString()+"
"
;

}

}

}

return strMessage;

}

script>



<html>

<head>

<title>Multiple File Upload with ASP.NETtitle>

head>

<body>

<b>Multiple File Upload Sampleb>

<form id="frmUp" enctype="multipart/form-data" runat="server">

Select file for upload:

<input id="txtFile" type="file" runat="server">

<br>

Select file for upload:

<input id="txtFile2" type="file" runat="server">

<br>

Select file for upload:

<input id="txtFile3" type="file" runat="server">

<br>

<span id=txtMsg runat="server" />

<br>

<input type=button id="Button1" value="Upload" OnServerClick="Button1_Click" runat="server">

form>

</body>

html>

0
Responses to ... Multi File Upload ASP.NET