我正在尝试上传文件。用户可以上传文件,但他/她可以上传图片而不是文件,我想限制这个如何应用条件这是我的上传代码
if (FileUploadControl.PostedFile != null &&
FileUploadControl.PostedFile.ContentLength
> 0)
{
if
(FileUploadControl.FileContent.Length < 100000)
{
string filename =
Path.GetFileName(FileUploadControl.PostedFile.FileName);
string folder = Server.MapPath("~/Docfiles/");
Directory.CreateDirectory(folder);
FileUploadControl.PostedFile.SaveAs(Path.Combine(folder, filename));
try
{
cc.upload1(Txt_docde.Value, txt_dname.Value,
FileUploadControl.FileName, Convert.ToInt32(Docdrop.SelectedValue),
Convert.ToInt32(DropDownList2.SelectedValue),
Convert.ToString(Session["Login2"]),Convert.ToInt32(Session["UserID"]));
StatusLabel.ForeColor = System.Drawing.Color.Green;
//StatusLabel.ForeColor = System.Drawing.FontStyle.Bold;
StatusLabel.Text = "Success";
}
catch
{
StatusLabel.ForeColor = System.Drawing.Color.Red;
Label2.Text = "Failed";
}
}
else
{
StatusLabel.ForeColor = System.Drawing.Color.Red;
Label2.Text = "File Size to big";
}
}