上传视频时出现内部服务器错误。但上传图片工作正常。有什么问题?

时间:2015-10-30 07:37:00

标签: javascript c# asp.net asp.net-mvc dropzone.js

我使用dropzone.js上传图片和视频。图片上传工作得很好。但是当我上传视频时,它会引发内部服务器错误。请帮我。 js文件中的maxFileSize为256MB,因此大小不存在问题。我在ASP.Net MVC工作

HTML

<div class="form-group">
            <label for="inputEmail3" class="col-sm-2 control-label">Upload Title Image</label>
            <div class="col-sm-8">
                <div class="main_page_area">
                    <div class="" id="container">
                        <div id="dropzone1" class="drag_area">Drag Here to Upload 1</div>
                        <div id="actions">
                            <div style="text-align:center"> <span style="display:none" class="btn btn-default fileinput-button"> <i class="glyphicon glyphicon-plus"></i> <span>Add files...</span> </span> </div>
                            <div style="width:100%;">
                                <span class="fileupload-process">
                                    <div id="total-progress" style="width:100%; margin-top:4px" class="progress progress-striped active" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0">
                                        <div class="progress-bar progress-bar-success" style="width:0%;" data-dz-uploadprogress> </div>
                                    </div>
                                </span>
                            </div>
                        </div>
                        <div style="margin-bottom:10px; ">
                            <table border="0" width="100%" id="table">
                                <tr>
                                    <td>

                                        <div id="previews">
                                            <ul class="loop_row">
                                                <li class="loop_row" id="template" style="list-style:none; cursor:move">
                                                    <table class="my_row_style">
                                                        <tr>
                                                            <td><span class="preview"><img data-dz-thumbnail alt="" title="" /></span></td>
                                                        </tr>
                                                    </table>
                                                </li>
                                            </ul>
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>

Dropzone JS代码

var previewNode = document.querySelector("#template");
    previewNode.id = "";
    var previewTemplate = previewNode.parentNode.innerHTML;
    previewNode.parentNode.removeChild(previewNode);
    var myDropzone = new Dropzone("#dropzone1", {
        url: "/AboutFtw/addaboutftw", // Set the url
        thumbnailWidth: 38,
        maxFiles: 1,
        thumbnailHeight: 38,
        parallelUploads: 1,
        previewTemplate: previewTemplate,
        autoQueue: true, 
        previewsContainer: "#previews", 
        clickable: ".fileinput-button", 
        init: function () {
            this.on("maxfilesexceeded", function (file) {
                this.removeAllFiles();
                this.addFile(file);
                //alert("Only one image");
            });
        }
    });

控制器ActionResult

   public ActionResult addaboutftw(FormCollection form_collection){
        int result = 0;
        HttpPostedFileBase file = Request.Files[0]; ;
        string folderid = Guid.NewGuid().ToString();
        if (file != null)
        {
           if (file.ContentLength != 0)
            {
                        result = _ftwCommonMethods.UploadImage(file, folderid);
             }
         }
          return View(new AboutFtwViewModel());
   }

我错过了什么吗?请记住,它正在用于图片上传

1 个答案:

答案 0 :(得分:0)

Maxrequest长度超过了我上传视频来解决这个问题我已经在web.config文件中设置了以下设置。它起作用了......

<system.web>
    <httpRuntime targetFramework="4.5"  maxRequestLength="1048576" />
</system.web>
<system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
    </security>
    <validation validateIntegratedModeConfiguration="false" />
</system.webServer>