string name = FileUpload1.FileName;
string size = FileUpload1.PostedFile.ContentLength.ToString();
string type = FileUpload1.PostedFile.ContentType;
string type2 = name.Substring(name.LastIndexOf(".") + 1);
string ipath = Server.MapPath("\upimg") + "\" + name;
string fpath = Server.MapPath("..\upfile") + "\" + name;
string wpath = "..\upimg\" + name;
if (type2 == "xls")
{
FileUpload1.SaveAs(fpath);
//Image1.ImageUrl = wpath;
Label1.Text = "你传的文件名称是:" + name + "<br>文件大小为:" + size + "字节<br>文件类型是:" + type + "<br>后缀名是:" + type2 + "<br>实际路径是:" + ipath + "<br>虚拟路径是:" + wpath;
Response.Redirect("index.asp?filename=" + name);
}
else
{
//Image1.Visible = false;
//FileUpload1.SaveAs(fpath);
Label1.Text = "<font color=red>请你选择.Microsoft Office Excel文件,格式为.xls。</font>";
string fpath = Server.MapPath("..\\upfile") + "\\" + name;这里提示用户代码为处理httpexception:“System.Web.HttpException”类型的异常在 System.Web.dll 中发生,但未在用户代码中进行处理。其他信息: 无法使用前导 .. 在顶级目录上退出。