久久久久久久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网址在线免费观看 | 911看片 | 国产一区二区三区在线 | 97精品超碰一区二区三区 | 免费观看一级毛片 | 午夜免费在线 | 欧美成人高清 | 欧美日在线 | 久久av一区二区三区亚洲 | 免费亚洲视频 | 亚洲最新视频 | 日本精品视频在线 | 手机看片福利永久 | 久久香蕉国产 | 欧美日韩高清 | 欧美一级全黄 | 91久久国产综合久久91精品网站 | 国产精品2区 | 国产成人av网站 | 欧美黄色一区二区 | 欧美成人精品欧美一级乱黄 | 91性高潮久久久久久久久 | 91视频精品 | 欧美在线视频免费 | 黄色网址入口 | 亚洲做受高潮无遮挡 | 婷婷中文网 | 日韩视频免费 | 成人深夜福利 | 国产精品第二页 | 特黄一级视频 | 亚洲欧美另类在线观看 | 欧美三级 欧美一级 | 国产一级黄色大片 | 免费一区二区三区 | 免费观看全黄做爰视频 | 日韩一区在线播放 | 日韩在线不卡 | 欧美日韩在线视频观看 | 日韩一级av毛片 | 久久亚洲免费视频 |