我正在使用dropzone,无法上传大于18MB的文档。我一直收到最大请求长度超出错误,无法理解原因。我已经研究了几天了,无法弄明白。我的配置示例如下。把我留下的头发拉到这个上面。
dropzone js代码:
$("#dz-documents").dropzone({
url: "/upload/UploadDocument",
maxFiles: 1,
maxFilesize: 500.0,
addRemoveLinks: true, //*** 2/19/15 RKH *** changed
uploadMultiple: false,
autoProcessQueue: true,
paramName: links,
height: '150px',
dictResponseError: 'Error uploading file!',
init: function () {
this.on("complete", function (file) {
if (this.getUploadingFiles().length === 0 && this.getQueuedFiles().length === 0) {
this.removeFile(file);
// reload documents
Documents.loadDocuments($('#hdfObjectId').val(), $('#hdfRecordId').val())
Activity[0].refreshActivity($('#hdfObjectId').val(), $('#hdfRecordId').val())
}
});
}
});
c#:
[HttpPost]
public async Task<ActionResult> UploadDocument()
{
try
{
// The Name of the Upload component is "files"
if (Request.Files != null)
{
OrganizationUser user = await ApplicationUserManager.GetOrganizationUser(User.Identity.GetUserId());
// snipped validation code
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(Microsoft.Azure.CloudConfigurationManager.GetSetting("avnCloudStorage"));
foreach (string name in Request.Files)
{
HttpPostedFileBase file = Request.Files[name];
if (await docRepository.Save(file, Request.Files.AllKeys, user.OrganizationID, user.ID, user.UserID.Value.ToString()))
{
return Content("Upload was successful");
}
else
{
return Content("Error occurred on upload");
}
}
}
return Content("Error occurred on upload");
}
catch (Exception ex)
{
logger.Error(ex);
throw ex;
}
}
的web.config
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" />
</requestFiltering>
</security>
</system.webServer>
<system.web>
<runtime executionTimeout="240" maxRequestLength="2097152">
<system.web>
答案 0 :(得分:2)
你能试试这个最大2GB:
<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>