예제 #1
0
        public ActionResult Upload(HttpPostedFileBase uploadFile)
        {
            string fileName = System.IO.Path.GetFileName(uploadFile.FileName);
            string filePhysicalPath = Server.MapPath("~/upload/" + fileName);
            string pic = "", error = "";

            try
            {
                uploadFile.SaveAs(filePhysicalPath);
                VideoConverter.Clear();
                bool success = VideoConverter.Tans2Mp4(filePhysicalPath);
                if (success)
                {
                    string destFile = VideoConverter.GetImage(filePhysicalPath);
                    pic = "/upload/" + Path.GetFileName(destFile);
                }
                else
                {
                    error = "转换失败!";
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(Json(new
            {
                pic = pic,
                error = error
            }));
        }