我正在尝试上传多个带有过滤扩展名的文件。即使我提供了正确的文件,我也无法上传文件。请帮我解决问题。
HttpFileCollection hfc = Request.Files;
for (int i = 0; i <= hfc.Count - 1; i++)
{
HttpPostedFile hpf = hfc[i];
string sFileExt1 = Path.GetExtension(hfc[i].FileName);
if (hpf.ContentLength > 0)
{
if (sFileExt1 != ".jpg" || sFileExt1 != ".jpeg")
{
//lblMsg.Text = "Extension not supported";
lblMsg.Text = sFileExt1.ToString();
break;
}
else
{
hpf.SaveAs(Server.MapPath("Special_Requests\\") + Path.GetFileName(hpf.FileName));
iUploadedCnt += 1;
lblMsg.Text = "File(s) upload successsfuly.";
}
}
}
啊哈