在MVC中上传视频时,拒绝访问路径XXX

时间:2016-10-13 14:03:18

标签: asp.net asp.net-mvc asp.net-mvc-3 asp.net-mvc-4

上传视频时,我有MVC应用程序抛出错误'访问路径XXX被拒绝'。上传图像时不会抛出错误。

我的代码中有什么东西拧干?

  [HttpPost]
        public ActionResult Index(HttpPostedFileBase video)
        {
            //var httpPostedFile = Request.Files[0];
            var ffMpeg = new NReco.VideoConverter.FFMpegConverter();   
            //ffMpeg.GetVideoThumbnail(Server.MapPath("~/Images"), "video_thumbnail.jpg");           

            var fileName = Path.GetFileName(video.FileName);
            var path = Server.MapPath("~/Images");
            video.SaveAs(path);
            ffMpeg.GetVideoThumbnail(path, "video_thumbnail.jpg");       


            return View();
        }

1 个答案:

答案 0 :(得分:0)

好吧,我会说你有问题

video.SaveAs(path);

因为路径不包含文件名(您尝试使用目录保存为" fileName")。

所以

var path = Server.MapPath("~/Images");
var fileName = Path.Combine(path, video.FileName);
video.SaveAs(fileName);
相关问题