我有一个将我的视频上传到文件夹的代码,它的文件路径存储在 sql server 数据库中。
我不知道如何在另一个单独的页面上播放视频
任何帮助或代码将不胜感激。
以下是我的上传代码
protected void btnInvoke_Click(object sender, EventArgs e)
{
string name = FileUpload1.PostedFile.FileName;
string ext = System.IO.Path.GetExtension(this.FileUpload1.PostedFile.FileName);
if (FileUpload1.PostedFile.ContentLength == 0)
{
Label1.Text = "Cannot upload zero length file";
}
if (ext == ".wmv" || ext == ".flv" || ext == ".avi" || ext == ".mp4" || ext == ".3GP" || ext == ".wma")
{
DateTime dt = DateTime.Now;
string tme = dt.ToLongTimeString();
string[] t = tme.Split(':');
string y = "";
foreach (string x in t)
{
y += x;
}
string aa = y + "_" + name;
string Video = FileUpload1.FileName;
string folder_path = Server.MapPath("~\\Video\\");
FileUpload1.SaveAs(folder_path + Video);
string loc = aa;
//Session["location1"] = loc;
SqlConnection sqlconn = new SqlConnection("Data Source=137.158.107.212;Initial Catalog=VideoDatabase;Persist Security Info=True;User ID=G0;Password=*********.");
SqlCommand sqlcomm = new SqlCommand("videoupload2", sqlconn);
sqlcomm.CommandType = CommandType.StoredProcedure;
sqlcomm.Parameters.Add("@video_name", SqlDbType.VarChar, 200).Value = videonametextbox.Text;
sqlcomm.Parameters.Add("@video_loc", SqlDbType.VarChar, 500).Value = loc;
sqlcomm.Parameters.Add("@video_language", SqlDbType.VarChar, 200).Value = languagetextbox.Text;
sqlconn.Open();
sqlcomm.ExecuteNonQuery();
sqlconn.Close();
Label2.Text = "Video Song uploaded Successfully";
}
else
{
Label2.Text = "please choose video file";
}
}