问题描述
- ASP.NET视频上传功能出错谁能帮我解决一下
-
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using JD.Model;
using JD.BLL;public partial class Admin_Conctrl_AddMTV : System.Web.UI.UserControl
{
int id;
MTV mtv;
protected void Page_Load(object sender, EventArgs e)
{
id = Convert.ToInt32(Request.QueryString["id"]);
if (!IsPostBack)
{
DropDownList1.DataSource = MTVTypeMananger.Get();
DropDownList1.DataBind();
}
if (id != 0)
{
mtv = MTVMananger.GetByID(id);
if (!IsPostBack)
{
TextBox1.Text = mtv.Title;
TextBox2.Text = mtv.Text;
DropDownList1.Items.FindByValue(mtv.Type.Id.ToString()).Selected = true;
CheckBox1.Checked = mtv.Order == 0 ? true : false;
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string mgf = string.Empty;
string filename = FileUpload1.FileName;
if (id == 0 && !FileUpload1.HasFile&&TextBox3.Text.Trim().Length==0)
{
Page.ClientScript.RegisterClientScriptBlock(GetType(), "key", "alert('请上传视频文件')", true);
return;
}
MTV b = new MTV();
if (FileUpload1.HasFile&&RadioButton2.Checked)
{
string str = filename.Substring(filename.LastIndexOf("."));
b.Url = "File/" + DateTime.Now.Ticks + str;
FileUpload1.PostedFile.SaveAs(MapPath("~/" + b.Url));
}
else if (TextBox3.Text.Trim().Length > 0 && RadioButton1.Checked)
b.Url = TextBox3.Text;
else
b.Url = mtv.Url;
b.Intime = DateTime.Now;
b.Text = TextBox2.Text;
b.Title = TextBox1.Text;
b.Order = CheckBox1.Checked ? 0 : 1;
b.Type = MTVTypeMananger.GetById(Convert.ToInt32(DropDownList1.SelectedValue));
try
{
if (id == 0)
MTVMananger.Add(b, ref mgf);
else
MTVMananger.Edit(id, b, ref mgf);
Response.Redirect("MTV.aspx?type=" + b.Type.Id);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
}
解决方案
报什么错都不说,鬼才知道。