日期:2014-05-17 浏览次数:20477 次
protected void bntup_Click(object sender, EventArgs e)
{
string getdatetime = DateTime.Now.ToString("yyMMddHHmmssfff");
string fileName = "Teacher\\Video\\" + getdatetime + System.IO.Path.GetExtension(uploadfile.FileName);
string sql = "insert into Video(Video_Name,Video_Path,Video_PostDate,TeacherName,College,Profession,Subject,Is_Rec,Is_Top) values('" + this.uploadfile.FileName + "','" + getdatetime + System.IO.Path.GetExtension(uploadfile.FileName) + "','" + DateTime.Now.ToString("yy/MM/dd HH:mm") + "','" + Session["UserName"].ToString() + "','" + this.DropDownList_college.SelectedValue + "','" + this.DropDownList_profession.SelectedValue + "','" + this.DropDownList_subject.SelectedValue + "','" + cbox + "','" + cbox2 + "')";
string filePath = uploadfile.PostedFile.FileName;
string fileExt = filePath.Substring(filePath.LastIndexOf(".") + 1);
if (uploadfile.FileName != "")
{
if (fileExt.ToLower() == "rmvb" || fileExt.ToLower() == "wmv" || fileExt.ToLower() == "swf" || fileExt.ToLower() == "flv")
{
string playFile = "Teacher/playFile/" + getdatetime + ".flv"; //playFile *1*
string videoImg = "Teacher/videoImg/" + getdatetime + ".jpg";
if (fileExt.ToLower() == "flv")
{
bool add = mydata.ExceSQL(sql); //不能放到if外面,否则即使不能上传文件,但数据库仍然会插入记录。
if (add)
{
uploadfile.SaveAs(Server.MapPath("~/" + fil