Multiple File Upload

Johnbhatt
Posted by Johnbhatt under ASP.NET category on | Points: 40 | Views : 1138
Uploading multiple Files and Printing their path in Label.
 protected void Button1_Click(object sender, EventArgs e)
{
string filePath = Server.MapPath("Uploads");
if (!Directory.Exists(filePath))
Directory.CreateDirectory(filePath);

HttpPostedFile fileObj;

Label1.Text = "Uploaded Files ";

int tc = Request.Files.Count;
string fname = "";
for (int i = 0; i < tc; i++)
{
fileObj = Request.Files[i];
if (fileObj.FileName != "")
{
fname = fileObj.FileName;
fileObj.SaveAs(filePath + "\\" + fname);
Label1.Text += "<li>" + fname;
}
}
}

Comments or Responses

Login to post response