ASP.NET里怎样上传视频啊,很急很急的说,亲们帮帮忙!请写下C#代码,感激不尽啊,多谢多谢!

ASP.NET里怎样上传视频啊,很急很急的说,亲们帮帮忙!请写下C#代码,感激不尽啊,多谢多谢!我想做成百度视频那种,就是图片上有个播放按钮,点击图片就弹出视频播放器进行... ASP.NET里怎样上传视频啊,很急很急的说,亲们帮帮忙!请写下C#代码,感激不尽啊,多谢多谢!
我想做成百度视频那种,就是图片上有个播放按钮,点击图片就弹出视频播放器进行播放了
展开
 我来答
没排名排名C2
2013-05-23 · TA获得超过275个赞
知道小有建树答主
回答量:190
采纳率:0%
帮助的人:175万
展开全部

恩,给你参考一下吧:

前台页面:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link href="../css/style.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="../../Plug/Editor/kindeditor-min.js" type="text/javascript"></script>
    <script src="../../Plug/jquery.validate/jquery.validate.js" type="text/javascript"></script>
    <link href="../../Plug/jquery.validate/jquery.validate.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        $(function () {
            $("#form1").validate();
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="crumbs">
    </div>
    <div id="wrapper">
        <div class="contain">
            <table border="0" cellpadding="0" cellspacing="0" class="table">
                <tr>
                    <th class="header" colspan="2">
                        企业视屏上传
                    </th>
                </tr>
                <%-- <tr>
                    <td class="tdl" style="width: 108px;">
                        <span class="red">*</span> 新闻标题:
                    </td>
                    <td class="tdr">
                        <asp:TextBox ID="txtName" runat="server" CssClass="tbox required" MaxLength="100"></asp:TextBox>
                    </td>
                </tr>--%>
                <tr>
                    <td class="tdl" style="width: 108px">
                        文件名:</td>
                    <td class="tdr ">
                        <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="tdl" style="width: 108px">
                        选择文件:
                    </td>
                    <td class="tdr ">
                        <br />
                        <asp:FileUpload ID="FileUpload" runat="server" />
                    <%--    <asp:LinkButton ID="lbtnDelImg" runat="server" Visible="false" OnClick="lbtnDelImg_Click">【删除文件】</asp:LinkButton>
                        <span class="tis">图片宽高比例:600*400,仅支持jpg、gif格式,图片大小200K以内</span>--%>
                    </td>
                </tr>
                <tr>
                    <td class="tdl" style="width: 108px;">
                        作者/上传人:</td>
                    <td class="tdr">
                        <asp:TextBox ID="txtAuthor" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <%--<tr>
                    <td class="tdl" style="width: 108px;">
                        <span class="red">*</span> 新闻内容:
                    </td>
                    <td class="tdr">
                        <textarea id="Content" runat="server" style="width: 80%; height: 300px;"></textarea>
                    </td>
                </tr>--%>
                <tr>
                    <td class="tdl" style="width: 108px;">
                    </td>
                    <td class="tdr">
                        <asp:CheckBox ID="ckRec" runat="server" Text="推荐" />
                        &nbsp;
                        <asp:CheckBox ID="ckLock" runat="server" Text="锁定" />
                    </td>
                </tr>
                <tr>
                    <td class="tdl" style="width: 108px">
                        排序ID:
                    </td>
                    <td class="tdr">
                        <asp:TextBox ID="txtSort" runat="server" Width="40px" MaxLength="4" Text="100" onkeyup="this.value=this.value.replace(/\D/g,'')"
                            onafterpaste="this.value=this.value.replace(/\D/g,'')"></asp:TextBox>
                        <span class="tis">数字越小越往前排序</span>
                    </td>
                </tr>
                <tr>
                    <td class="foot">
                    </td>
                    <td class="foot">
                        &nbsp;<asp:Button ID="btnUpImg" runat="server" Text="上传" CssClass="button" OnClick="btnUpImg_Click" />
                    &nbsp;<input type="button" value="返回列表" onclick="window.location.href='List.aspx';" class="button" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
    </form>
</body>
</html>

后台代码:

protected void btnUpImg_Click(object sender, EventArgs e)
        {
            if (FileUpload.HasFile)
            {
                string url = "";
                string type = "";
                int size = 0;
                string guid = "";
                int pid = 57;
                int id = Falcon.Function.GetQueryInt("id", 0);
                string path = Server.MapPath("~/Files/");
                if (FileUpload.HasFile)
                {
                    var file = Request.Files[0];
                    string filename = Path.GetFileName(file.FileName);
                    guid = Guid.NewGuid().ToString() + "_" + filename;
                    string fullpath = Path.Combine(path, guid);
                    url = "/Files/" + guid;
                    type = file.ContentType;
                    size = file.ContentLength;
                    file.SaveAs(fullpath);
                }
                string author = txtAuthor.Text;
                int sort = Falcon.Function.ToInt(txtSort.Text.Trim(), 100);
                if (id == 0)
                {
                    if (new BLL.F_Files().Add(pid, txtName.Text.Trim().ToString(), url, author, size, type, ckRec.Checked, ckLock.Checked, sort))
                    {
                        Response.Redirect("list.aspx");
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "", "alert('添加失败!')", true);
                    }
                }
                else
                {
                    if (new BLL.F_Files().Update(id, pid, txtName.Text.Trim().ToString(), url, author, size, type, ckRec.Checked, ckLock.Checked, sort))
                    {
                        Response.Redirect("list.aspx");
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "", "alert('修改失败!')", true);
                    }
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请选择文件!')", true);
            }
        }

效果如下:

百度网友1e52b2c
2013-05-23 · 超过16用户采纳过TA的回答
知道答主
回答量:60
采纳率:0%
帮助的人:42.9万
展开全部
其实你只要当作一个文件上传就行了,然后改下config的默认4M配置就行了。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式