首页 > 解决方案 > 即使在 DropZone 中将 maxFilesize 设置为 500,也无法加载文件大小超过 20MB 的文件

问题描述

for (int i = 0; i < Request.Files.Count; i++)
                {
                    HttpPostedFileBase file = Request.Files[i];
                    //Save file content goes here
                    fName = file.FileName;
                    if (file != null && file.ContentLength > 0)
                    {
}}

以上是我获取文件并保存到自定义路径的 C# 代码。

Dropzone.options.dropzoneForm = {
            autoProcessQueue: false,
            uploadMultiple: true,
            parallelUploads: 100,
            maxFiles: 100,
            maxFilesize: 500,
            acceptedFiles: 'image/jpeg,image/png,image/tiff,application/pdf,.pdf,.jpeg,.jpg,.tiff,.tif,.pdf',
            init: function () {}}  

以上是我的 dropzone 的 java 脚本代码。在这里,我将 maxFilesize 指定为 500MB,我正在尝试上传 22MB 大小的文件,在 C# 中出现“超出最大请求长度”的错误,并且 Request.Files.Count 显示为 0 计数。请帮助我。在此先感谢。

标签: javascriptc#html

解决方案


它允许上传最大大小为 2GB 的文件。在 web.config 文件中更新此设置

<system.web>
  <compilation debug="true" targetFramework="4.5" />
  <httpRuntime targetFramework="4.5" maxRequestLength="2147483" executionTimeout="1600" requestLengthDiskThreshold="2147483647" />
</system.web>

<system.webServer>
  <security>
    <requestFiltering>
      <requestLimits maxAllowedContentLength="2147483647" />
    </requestFiltering>
  </security>
</system.webServer>

推荐阅读