首页 > 代码库 > asp.net mvc中实现视频自动上传

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

         在视频上传这儿做了好长时间,想了很多办法。因为想做的是当点击图标的时候就让视频自动开始上传不需要点提交按钮,而上传控件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=http://www.mamicode.com/images/上传图标.jpg" />>

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


   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中实现视频自动上传