视频上传问题
我写了一段简单的代码可以实现视频和图片的上传,但是我想要再视频文件夹中只能上传格式为*.avi *.rmvb *.rm *.asf 的文件而图片文件夹只能上传格式为*.bmp *.gif *.jpeg的文件,需要怎样修改?
我的源代码为:
string categories = this.dm.SelectedValue.ToString();
string biaoti = this.mx.Text;
string jishu = this.TextBox1.Text;
string time = nowtime.Year + "年" + nowtime.Month + "月" + nowtime.Day + "日";
string Path;
string Path1;
string file = "Admin/shipin/" + this.FileUpload1.FileName;
string tupian = "Admin/shipin/" + this.FileUpload2.FileName;
useradd.sql = "insert into tb_dj(jnumber,jtime,jdb,jfile,jsv,jmx,jtp) values('" + jishu + "','" + time + "',0,'" + file + "','" + categories + "','" +biaoti + "','" + tupian + "')";
useradd.sqlconnection(useradd.sql);
Path = Server.MapPath("~/") + "Admin/ShiPin" + "\\" + this.FileUpload1.FileName;
Path1 = Server.MapPath("~/") + "Admin/ShiPinImages" + "\\" + this.FileUpload2.FileName;
FileUpload1.PostedFile.SaveAs(Path);
FileUpload2.PostedFile.SaveAs(Path1);
Label1.Text = "上传成功";
mx.Text = "";
TextBox1.Text = ""
跪求答案啊!
------解决方案--------------------
string strExtn = System.IO.Path.GetExtension(FileUpload2.FileName).ToLower();
List<string> lsittype=new List<string>(){".avi",".rmvb",".rm",".asf"};
//*.avi *.rmvb *.rm *.asf
if (!lsittype.Contains(strExtn))
{
Response.Write("<script>alert('请上传文件类型错误!');</script>");
return;
}
else
{
//你的处理
}