Code Snippet posted by:
Johnbhatt | Posted on: 7/7/2012 | Category:
ASP.NET Codes | Views: 461 | Status:
[Member] |
Points: 40
|
Alert Moderator
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;
if (fileObj.FileName != "")
{
fname = fileObj.FileName;
fileObj.SaveAs(filePath + "\\" + fname);
Label1.Text += "<li>" + fname;
}
}
}
John Bhatt
Glad to Know, Free to Share.....
http://www.johnbhatt.com