protected void btnupload_Click(object sender, EventArgs e) { try { Upldmtrl.Visible = false; string fileext = System.IO.Path.GetExtension(Upldmtrl.FileName).ToLower(); // stores extension of the uploaded file. string filename = Upldmtrl.FileName; // store name of the uploade file in filename. filename = filename.Remove(filename.Length - 4); Session["title"] = filename; Upldmtrl.SaveAs(Server.MapPath("/Upload/Videos/") + Upldmtrl.FileName); string filepath = Server.MapPath("/Upload/Videos/") + Upldmtrl.FileName; Session["file"] = filepath; UploadVideos(Upldmtrl.FileContent, Upldmtrl.PostedFile.ContentType, Upldmtrl.FileName, filepath); int lessonid = (int)Session["lessonid"]; int subjectid = (int)Session["subjectid"]; int classid = (int)Session["classid"]; string title = Convert.ToString(Session["title"]); int filesize = Upldmtrl.PostedFile.ContentLength; if (Session["uploadcompleted"] != null) { string videoid = Session["videoid"].ToString(); if (UserBL.VideoMaterial(2, classid, subjectid, lessonid, videoid, title)) { string FileToDelete = Convert.ToString(Session["file"]); //Delete temporary video after uploading to youtube. System.IO.File.Delete(FileToDelete); Label lbl = new Label(); lbl.Text = Convert.ToString(Session["uploadcompleted"]); fillVidgrid(); show = "upload"; Response.Redirect(Request.RawUrl, false); } else { show = "failure"; Response.Redirect(Request.RawUrl); } } } catch (Exception ex) { CreateLog err = new CreateLog(); CreateLog.CreateLogFiles(); err.ErrorLog(Server.MapPath("/Logs/ErrorLog.txt"), ex.Message); } finally { lblclassname.Visible = false; ddlClass.Visible = false; lblSubject.Visible = false; ddlsubject.Visible = false; lblchapter.Visible = false; ddllesson.Visible = false; lblbrowseFile.Visible = false; Upldmtrl.Visible = false; btnupload.Visible = false; lblVidDescription.Visible = false; txtVidDescription.Visible = false; } }
protected void btnupload_Click(object sender, EventArgs e) { try { int filesize = Upldmtrl.PostedFile.ContentLength; string filename = Upldmtrl.FileName; Upldmtrl.SaveAs(Server.MapPath("/Upload/Articles/") + Upldmtrl.FileName); string file = Server.MapPath("/Upload/Articles/") + Upldmtrl.FileName; Session["Docfile"] = file; string f = Upldmtrl.FileName; var fname = Path.ChangeExtension(f, "html"); string path = Server.MapPath("/Upload/Articles/") + fname; Htmlconversion(file, path, fname); if (ddlTypeUpload.SelectedItem.ToString() == "ARTICLE") { int typeid = Convert.ToInt32(ddlTypeUpload.SelectedValue); if (UserBL.ArticleUpload(fname, typeid, filesize, ("/Upload/Articles/") + fname)) { string FileToDelete = Session["Docfile"].ToString(); File.Delete(FileToDelete); show = "upload"; Response.Redirect(Request.RawUrl); } else { show = "failure"; Response.Redirect(Request.RawUrl); } } else if (ddlTypeUpload.SelectedItem.ToString() == "NEWS") { int typeid = Convert.ToInt32(ddlTypeUpload.SelectedValue); if (UserBL.ArticleUpload(fname, typeid, filesize, ("/Upload/Articles/") + fname)) { string FileToDelete = Session["Docfile"].ToString(); File.Delete(FileToDelete); show = "upload"; Response.Redirect(Request.RawUrl); } else { show = "failure"; Response.Redirect(Request.RawUrl); } } } catch (Exception ex) { throw ex; } }
protected void btnupload_Click(object sender, EventArgs e) { try { int classid = (int)Session["classid"]; int typeid = Int32.Parse(ddlTypeUpload.SelectedValue); Session["typeid"] = typeid; string fileext = System.IO.Path.GetExtension(Upldmtrl.FileName).ToLower(); // stores extension of the uploaded file. string filename = Upldmtrl.FileName; // store name of the uploade file in filename. if (ddlTypeUpload.SelectedItem.ToString() == "QUESTION PAPER") { int subjectid = (int)Session["subjectid"]; ddlTypeUpload.ClearSelection(); Upldmtrl.SaveAs(Server.MapPath("/Upload/QuestionPapers/") + Upldmtrl.FileName); string str = Server.MapPath("/Upload/QuestionPapers/") + Upldmtrl.FileName; int filesize = Upldmtrl.PostedFile.ContentLength; if (UserBL.QuestionPaperUpload(typeid, classid, subjectid, filesize, ("/Upload/QuestionPapers/") + filename)) { fillQgrid(); show = "upload"; Response.Redirect(Request.RawUrl); } else { show = "failure"; Response.Redirect(Request.RawUrl); } } else if (ddlTypeUpload.SelectedItem.ToString() == "SYLLABUS") { int subjectid = (int)Session["subjectid"]; ddlTypeUpload.ClearSelection(); Upldmtrl.SaveAs(Server.MapPath("/Upload/Syllabus/") + Upldmtrl.FileName); string str = Server.MapPath("/Upload/Syllabus/") + Upldmtrl.FileName; int filesize = Upldmtrl.PostedFile.ContentLength; if (UserBL.SyllabusUpload(typeid, classid, subjectid, filesize, ("/Upload/Syllabus/") + filename)) { fillQgrid(); show = "upload"; Response.Redirect(Request.RawUrl); } else { show = "failure"; Response.Redirect(Request.RawUrl); } } else if (ddlTypeUpload.SelectedItem.ToString() == "DOCUMENT") { int lessonid = (int)Session["lessonid"]; int subjectid = (int)Session["subjectid"]; Upldmtrl.SaveAs(Server.MapPath("/Upload/pdf/") + Upldmtrl.FileName); string file = Server.MapPath("/Upload/pdf/") + Upldmtrl.FileName; string f = Upldmtrl.FileName; Session["Docfile"] = file; int filesize = Upldmtrl.PostedFile.ContentLength; var fname = Path.ChangeExtension(f, "html"); string path = Server.MapPath("/Upload/pdf/") + fname; Htmlconversion(file, path, fname); // replaceinFile(path); if (UserBL.Material(typeid, classid, subjectid, lessonid, filesize, ("/Upload/pdf/") + fname)) { string FileToDelete = Session["Docfile"].ToString(); File.Delete(FileToDelete); ddlTypeUpload.ClearSelection(); fillgrid(); show = "upload"; Response.Redirect(Request.RawUrl); } else { // lblmsg.Text = " Upload UnSucessful"; ddlTypeUpload.ClearSelection(); show = "failure"; Response.Redirect(Request.RawUrl); } } } catch (Exception ex) { CreateLog err = new CreateLog(); CreateLog.CreateLogFiles(); err.ErrorLog(Server.MapPath("/Logs/ErrorLog.txt"), ex.Message); } finally { ddlTypeUpload.ClearSelection(); lblclassname.Visible = false; ddlClass.Visible = false; lblSubject.Visible = false; ddlsubject.Visible = false; lblchapter.Visible = false; ddllesson.Visible = false; lbltitle.Visible = false; ddltitle.Visible = false; lblbrowseFile.Visible = false; Upldmtrl.Visible = false; btnupload.Visible = false; lbltype.Visible = false; ddlTypeUpload.Visible = false; } }