久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <small id='sFvqV'></small><noframes id='sFvqV'>

  1. <i id='sFvqV'><tr id='sFvqV'><dt id='sFvqV'><q id='sFvqV'><span id='sFvqV'><b id='sFvqV'><form id='sFvqV'><ins id='sFvqV'></ins><ul id='sFvqV'></ul><sub id='sFvqV'></sub></form><legend id='sFvqV'></legend><bdo id='sFvqV'><pre id='sFvqV'><center id='sFvqV'></center></pre></bdo></b><th id='sFvqV'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='sFvqV'><tfoot id='sFvqV'></tfoot><dl id='sFvqV'><fieldset id='sFvqV'></fieldset></dl></div>
    1. <tfoot id='sFvqV'></tfoot>
        <bdo id='sFvqV'></bdo><ul id='sFvqV'></ul>
    2. <legend id='sFvqV'><style id='sFvqV'><dir id='sFvqV'><q id='sFvqV'></q></dir></style></legend>

    3. ASP MVC 文件上傳 HttpPostedFileBase 為空

      ASP MVC FIle Upload HttpPostedFileBase is Null(ASP MVC 文件上傳 HttpPostedFileBase 為空)
        <legend id='UpKNh'><style id='UpKNh'><dir id='UpKNh'><q id='UpKNh'></q></dir></style></legend>

        1. <tfoot id='UpKNh'></tfoot>
            <tbody id='UpKNh'></tbody>

            <small id='UpKNh'></small><noframes id='UpKNh'>

              <i id='UpKNh'><tr id='UpKNh'><dt id='UpKNh'><q id='UpKNh'><span id='UpKNh'><b id='UpKNh'><form id='UpKNh'><ins id='UpKNh'></ins><ul id='UpKNh'></ul><sub id='UpKNh'></sub></form><legend id='UpKNh'></legend><bdo id='UpKNh'><pre id='UpKNh'><center id='UpKNh'></center></pre></bdo></b><th id='UpKNh'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='UpKNh'><tfoot id='UpKNh'></tfoot><dl id='UpKNh'><fieldset id='UpKNh'></fieldset></dl></div>
              • <bdo id='UpKNh'></bdo><ul id='UpKNh'></ul>
              • 本文介紹了ASP MVC 文件上傳 HttpPostedFileBase 為空的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                在我的控制器中,因為我希望能夠填寫有關視頻的一些詳細信息并實際上傳它,所以 Video 類不需要實際的視頻,因為它將被傳遞給另一個 Web 服務.

                In my controller I have, because I wanted to be able to fill out some details about the video and actually upload it, the Video class doesn't need the actual video because it's going to be passed to another web service.

                public class VideoUploadModel
                    {
                        public HttpPostedFileBase vid { get; set; }
                        public Video videoModel { get; set; }
                    }
                
                    //
                    // POST: /Video/Create
                    [HttpPost]
                    public ActionResult Create(VideoUploadModel VM)
                    {
                        if (ModelState.IsValid)
                        {
                            db.Videos.AddObject(VM.videoModel);
                            db.SaveChanges();
                            return RedirectToAction("Index");  
                        }
                
                        ViewBag.UserId = new SelectList(db.DBUsers, "Id", "FName", VM.videoModel.UserId);
                        return View(VM);
                    }
                

                在我看來我有

                @model LifeHighlightsShoeLace.Controllers.VideoController.VideoUploadModel
                @{
                   ViewBag.Title = "Create";
                }
                
                <h2>Create</h2>
                
                <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
                

                @using (Html.BeginForm("Create", "Video", FormMethod.Post, new { enctype = "multipart/form-data" }))
                {
                @Html.ValidationSummary(true)
                <fieldset>
                    <legend>Video</legend>
                
                    <div class="editor-label">
                        @Html.LabelFor(model => model.videoModel.KalturaID)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.videoModel.KalturaID)
                        @Html.ValidationMessageFor(model => model.videoModel.KalturaID)
                    </div>
                
                    <div class="editor-label">
                        @Html.LabelFor(model => model.videoModel.Size)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.videoModel.Size)
                        @Html.ValidationMessageFor(model => model.videoModel.Size)
                    </div>
                
                    <div class="editor-label">
                        @Html.LabelFor(model => model.videoModel.Date)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.videoModel.Date)
                        @Html.ValidationMessageFor(model => model.videoModel.Date)
                    </div>
                
                    <div class="editor-label">
                        @Html.LabelFor(model => model.videoModel.UploadedBy)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.videoModel.UploadedBy)
                        @Html.ValidationMessageFor(model => model.videoModel.UploadedBy)
                    </div>
                
                    <div class="editor-label">
                        @Html.LabelFor(model => model.videoModel.UserId, "User")
                    </div>
                
                    <div class="editor-field">
                        @Html.DropDownList("UserId", String.Empty)
                        @Html.ValidationMessageFor(model => model.videoModel.UserId)
                    </div>
                    <div class="editor-field">
                    <input name="model.vid" type="file" />
                    </div>
                    <p>
                        <input type="submit" value="Create" />
                    </p>
                </fieldset>
                

                }

                當我提交表單時,VM 的 videoModel 部分已填寫,但實際文件為空.有什么想法嗎?

                When I submit the form the videoModel part of VM is filled out but vid the actual file is null. Any ideas?

                推薦答案

                根據OP評論更新

                在 web.config 文件中設置最大文件長度改變?"到您希望最大的文件大小,例如 65536 是 64MB

                set the Max file length in the web.config file Change the "?" to a file size that you want to be your max, for example 65536 is 64MB

                <configuration>
                  <system.web>
                    <httpRuntime maxRequestLength="?" /> 
                  </system.web>
                </configuration>
                

                您不能將文件添加到模型中,它將在它自己的字段中,而不是模型的一部分

                You can't add the file to the model, it will be in it's own field not part of the model

                <input name="videoUpload" type="file" />
                

                您的操作不正確.它需要接受文件作為它自己的參數(或者如果多個使用 IEnumerable 作為參數類型)

                Your action is incorrect. It needs to accept the file as it's own parameter (or if multiple use IEnumerable<HttpPostedFileBase> as the parameter type)

                [HttpPost]
                public ActionResult Create(VideoUploadModel VM, HttpPostedFileBase videoUpload)
                {
                    if (ModelState.IsValid)
                    {
                        if(videoUpload != null) { // save the file
                            var serverPath = server.MapPath("~/files/" + newName);
                            videoUpload.SaveAs(serverPath);
                        }
                
                        db.SaveChanges();
                        return RedirectToAction("Index");  
                    }
                
                    ViewBag.UserId = new SelectList(db.DBUsers, "Id", "FName", VM.videoModel.UserId);
                    return View(VM);
                }
                

                如果您允許選擇多個文件,則必須允許這樣做

                If you were allowing multiple files to be selected you have to allow for that

                [HttpPost]
                public ActionResult Create(VideoUploadModel VM, IEnumerable<HttpPostedFileBase> videoUpload)
                {
                    if (ModelState.IsValid)
                    {
                        if(videoUpload != null) { // save the file
                            foreach(var file in videoUpload) {
                                var serverPath = server.MapPath("~/files/" + file.Name);
                                file.SaveAs(serverPath);
                            }
                        }
                
                        db.SaveChanges();
                        return RedirectToAction("Index");  
                    }
                
                    ViewBag.UserId = new SelectList(db.DBUsers, "Id", "FName", VM.videoModel.UserId);
                    return View(VM);
                }
                

                這篇關于ASP MVC 文件上傳 HttpPostedFileBase 為空的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                What are good algorithms for vehicle license plate detection?(車牌檢測有哪些好的算法?)
                onClick event for Image in Unity(Unity中圖像的onClick事件)
                Running Total C#(運行總 C#)
                Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(單擊帶有 JAvascript.ASP.NET C# 的超鏈接時刪除目錄)
                asp.net listview highlight row on click(asp.net listview 在單擊時突出顯示行)
                Calling A Button OnClick from a function(從函數調用按鈕 OnClick)
              • <tfoot id='IFUO8'></tfoot>
                  1. <small id='IFUO8'></small><noframes id='IFUO8'>

                      <legend id='IFUO8'><style id='IFUO8'><dir id='IFUO8'><q id='IFUO8'></q></dir></style></legend>

                        <i id='IFUO8'><tr id='IFUO8'><dt id='IFUO8'><q id='IFUO8'><span id='IFUO8'><b id='IFUO8'><form id='IFUO8'><ins id='IFUO8'></ins><ul id='IFUO8'></ul><sub id='IFUO8'></sub></form><legend id='IFUO8'></legend><bdo id='IFUO8'><pre id='IFUO8'><center id='IFUO8'></center></pre></bdo></b><th id='IFUO8'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='IFUO8'><tfoot id='IFUO8'></tfoot><dl id='IFUO8'><fieldset id='IFUO8'></fieldset></dl></div>
                          <tbody id='IFUO8'></tbody>
                          <bdo id='IFUO8'></bdo><ul id='IFUO8'></ul>
                          主站蜘蛛池模板: 精品精品 | 欧美网站一区二区 | 久久国产激情视频 | 日本视频一区二区三区 | 大陆一级毛片免费视频观看 | 精品免费av | 精品一区免费 | 中国av在线免费观看 | 成人欧美一区二区三区黑人孕妇 | 精品久久久久久亚洲综合网站 | 亚洲成人在线免费 | 天天天天操 | 国产精品亚洲一区 | 亚洲高清免费视频 | 偷拍自拍网| 超碰人人在线 | 日韩国产一区二区三区 | 亚洲成人黄色 | 久久蜜桃av一区二区天堂 | 高清国产一区二区 | 日韩一区二区久久 | 日本在线观看视频 | 国内精品在线视频 | 欧美日韩亚洲视频 | 久久国内精品 | 久久精品一区二区 | a级大片免费观看 | 亚洲高清中文字幕 | 黄色一级片aaa | 欧美中文在线 | 日屁视频| 九九亚洲精品 | 久久精品小视频 | 国产在线一区观看 | 天堂视频中文在线 | 亚洲精品免费在线观看 | 国产黄色av电影 | 一级毛片视频在线观看 | 成人免费在线观看 | 人人干人人爽 | 亚洲国产免费 |