我无法通过 asp 上传文件:FileUpload 总是 FileUpload1.HasFile 是错误的以下是我尝试上传文件的代码,但不幸的是我仍然无法上传文件
ASPX 代码
c#代码后面的代码
protected void btSave_Click(object sender, EventArgs e)
{
try
{
noteFile = "";
/*File is existed or not cheked**/
if (FileUpload1.HasFile)
{
/*File Size Checked*/
if (FileUpload1.FileBytes.Length < 1024 * 1000)
{
/*File Type Checked*/
string fileType=Path.GetExtension(FileUpload1.FileName);
if (fileType == ".xls" || fileType == ".doc")
{
/*get the last 'noteID' and add 1 to noteID*/
dt.Clear();
dt = dConnect.noteInfo(0, "", "", "", "", "", "", "", "admin");
noteID = 0;
/*Check the file name if any singal gile is save then need to delete it*/
dt.Clear();
dt = dConnect.noteInfo(0, "", "", "", "", "", "", dt.Rows[0]["noteID"].ToString() + '_', "byAdminFile");
exceprionString = "";
exceprionString = dConnect.exceptionMessage();
if (dt.Rows.Count == 0 && exceprionString.Equals(""))
{
noteID = 1 + Convert.ToInt32(dt.Rows[0]["noteID"].ToString());
FileUpload1.SaveAs(Server.MapPath("~/note") + noteID.ToString() + '_' + FileUpload1.FileName);
noteFile = noteID.ToString() + '_' + FileUpload1.FileName;
}
else
{
noteFile = "";
SMS("Only One File Can Stor Per Note");
}
}
else
SMS("Only Word or Excel File Can Upload");
}
else
SMS("File Size Should Not More Than 1 MB");
}
else
{
noteFile = "";
SMS(FileUpload1.FileName.ToString());
}
}
catch (Exception ex)
{
throw ex;
}
}