I want to validate multiple uploaded files. It should accept only .png and .jpg files. Below is my code:
protected void uploadFile_Click(object sender, EventArgs e)
{
if (multipleFile.HasFiles)
{
string filenameWithPath = string.Empty;
foreach (HttpPostedFile uploadedFile in multipleFile.PostedFiles)
{
filenameWithPath = System.IO.Path.Combine(
Server.MapPath("~/Uploads/"),
uploadedFile.FileName);
uploadedFile.SaveAs( filenameWithPath );
ltStatusText.Text += "File-<b>"
+ uploadedFile.FileName
+ "</b> uploaded successfully.<br>";
}
}
}