码迷,mamicode.com
首页 > Web开发 > 详细

asp.net mvc中实现视频自动上传

时间:2015-01-31 00:28:26      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

         在视频上传这儿做了好长时间,想了很多办法。因为想做的是当点击图标的时候就让视频自动开始上传不需要点提交按钮,而上传控件file需要点击提交按钮之后才能上传。        

<body>
    <div class="container">

        <div class="panel ">

            <div class="header">
                <p>上传视频</p>
            </div>
            <div class="panel-body">
                <div class="row-fluid">
                    <div class="picture">
                        <img style="cursor: pointer;" alt="" id="shangchuan" src="../../images/上传图标.jpg" />
                    </div>
                    <div class="picture2">
                      @* @using (Html.BeginForm("Index", "UpLoad", FormMethod.Post, new { enctype = "multipart/form-data" }))
                        { 
                        *@<form name="form1" action="/Upload" method ="post"enctype = "multipart/form-data" ><input type="file" name="file" id="myfile" value="" onchange ="UploadFile();" />
                           @*<input type="submit" name="Submit" id="Submit" />*@ </form>
                                 
                              
                       @* }*@</div>
                </div>
                <div class="t">上传视频,即表示您已同意<a href="Declaration"><strong>校园视频上传服务条款</strong></a>,请勿上传色情,反动等违法视频</div>


                <hr />
            </div>

        </div>
    </div>

</body>

      效果如图:(有待上传。)


   Controller 里:     

public class UpLoadController : Controller
    {
        
         //GET: /UpLoad/

        public ActionResult Index()
        {
            return View();
        }
        public ActionResult Declaration()
        {
            return View();
        }

        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Index(HttpPostedFileBase file,  uploadModel model)
        {
            if (file.ContentLength > 0)
            {
                //获得保存路径
                string filePath = Path.Combine(HttpContext.Server.MapPath("~/Uploads"),
                                Path.GetFileName(file.FileName));
                file.SaveAs(filePath);

                model.vedio = filePath;
                model.Id = Guid.NewGuid();
                //model.Id=Request["text"];
                uploadDB.UploadModel.AddVedio(model);

               
            }
            return View();
        }

    }
             视频的上传完成了,上传时候的进度条又是一个难点。还要继续攻克。

       

asp.net mvc中实现视频自动上传

标签:

原文地址:http://blog.csdn.net/mqplw/article/details/43319745

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!