Upload and download video

Apr 27 2020 9:25 AM
I put my webform(UserPage.aspx) in a rootfolder named UpdatePage, and I'm Uploading my Videos In different root folder named: UploadedVideos. Everything is working fine. but when I'm retrieving the Path of the video from the sql server and pass it to the video player in the Gridview, it is looking for the video in UpdatePage/UploadVideos/filename.mp4 instead of root folder UploadVideos/Filename.mp4.
 
How to solve the issue??
 
Backend code for uploading file and saving path:
  1. if (fileupload1.HasFile && fileupload1.PostedFile != null && fileupload1.PostedFile.FileName != "")  
  2. {  
  3. Bal objBal = new Bal();  
  4. try  
  5. {  
  6. string filename = Path.GetFileName(fileupload1.PostedFile.FileName);  
  7. fileupload1.PostedFile.SaveAs(Server.MapPath("~/UploadedVideos/" + filename));  
  8. string filepathtostore = string.Format("UploadedVideos/"+filename);  
  9. objBal.VideoFilePath = filepathtostore;  
  10. objBal.Description = txtDesc.Text.Trim();  
  11. objBal.Course = dropdownlist1.SelectedItem.ToString();  
  12. objBal.filetype = dropdownlist2.SelectedItem.ToString();  
  13. int result = objBal.AdminUploadPhysicsVideoBalFunc(objBal);  
  14. if(result>0)  
  15. {  
  16. labelmsg.Visible = true;  
  17. labelmsg.ForeColor = System.Drawing.Color.Green;  
  18. labelmsg.Text = "Video File Updated Successfully";  
  19. }  
  20. else  
  21. {  
  22. labelmsg.Visible = true;  
  23. labelmsg.ForeColor = System.Drawing.Color.Red;  
  24. labelmsg.Text = "Can't Upload File Try Again.";  
  25. }  
  26. BindVideoPanel();  
  27. }  
  28. catch(Exception ex)  
  29. {  
  30. throw ex;  
  31. }  
  32. finally  
  33. {  
  34. objBal = null;  
  35. }  
  36. }  
Backend code for binding Gridview::
  1. private void BindVideoPanel()  
  2. {  
  3. DataSet ds = new DataSet();  
  4. Bal objBal = new Bal();  
  5. try  
  6. {  
  7. ds = objBal.BindVideoPanelBalFunc();  
  8. VideoGridView.DataSource = ds;  
  9. VideoGridView.DataBind();  
  10. }  
  11. catch(Exception ex)  
  12. {  
  13. throw ex;  
  14. }  
  15. finally  
  16. {  
  17. objBal = null;  
  18. }  
  19. }  
Frontend HTML :
 
DataKeyNames="Id" OnPageIndexChanging="VideoGridView_PageIndexChanging" OnRowDeleting="VideoGridView_RowDeleting" AllowPaging="true">

Answers (1)