private void btnup_Click(object sender, System.EventArgs e)
{
//判断上传文件的大小
if(musicup.PostedFile.ContentLength>20485760 )
{
Response.Write("<script language='javascript'>alert('你上传的文件太大,超过了2048576字节!只能传部分数据');</script>");
}
string fullFileName=this.musicup.PostedFile.FileName;
string fileName=fullFileName.Substring(fullFileName.LastIndexOf("\\")+1);
string type=fullFileName.Substring(fullFileName.LastIndexOf(".")+1);
if(type=="mp3"||type=="avi")
{
this.musicup.PostedFile.SaveAs(Server.MapPath("../teacher/music")+"\\"+fileName);
}
else
{
Response.Write("<script language='javascript'>alert('你没有选择文件或者选择的文件格式不正确!');</script>");
}
string filePath="../teacher/music/"+fileName;
// string strconn=ConfigurationSettings.AppSettings["dsn"];
SqlConnection conn=new SqlConnection(Application["conStr"].ToString());
conn.Open();
string strsql="insert into Collection(Col_name,Col_path,Singer,Col_remark,teaID,Col_authority) values('"+fileName+"','"+filePath+"','"+tbsinger.Text+"','"+tbremark.Text+"','"+Session["Teacherid"].ToString()+"','"+ddl.SelectedItem.Value+"')";
SqlCommand cmd=new SqlCommand(strsql,conn);
try
{
cmd.ExecuteNonQuery();
}
catch
{
Response.Write("有错误!");
}
conn.Close();
tbremark.Text="";
tbsinger.Text="";
BindData();
}
这个将文件路径查入到了数据库,但不知道应该怎么播放呢,那位大侠指点指点