【问题标题】:system.out of memory exception in file uploadsystem.out of memory 文件上传异常
【发布时间】:2014-05-14 08:00:27
【问题描述】:

我想使用 ASP.NET 上传 1 GB 的文件。我写这段代码

 Dim bytes(up_FileImage.UploadedFiles(0).ContentLength) As Byte
                    bytes = File.ReadAllBytes(Path.Combine(Request.PhysicalApplicationPath, "App_Data/", ViewState("DirectoreName").ToString(), up_FileImage.UploadedFiles(0).FileName))
                    itemDocFile.FileImage = bytes

并在 web.config 中编写此代码

<httpRuntime maxRequestLength="102400" executionTimeout="3600"/>

但是在第一行我得到了这个错误

system.out of memory exception

请帮助我。谢谢大家

【问题讨论】:

  • IIS默认大小只有4MB,所以上传1GB大小的文件会报错,尝试从webconfig文件中设置文件大小。
  • @Krunal Patil:我更新了问题。谢谢。
  • File.ReadAllBytes() 意味着您会将所有内容加载到内存中。如果可以的话,尽量避免这种情况。

标签: asp.net vb.net telerik radupload


【解决方案1】:

不建议上传过大的文件。这里有一些替代方案: https://stackoverflow.com/a/17904718/902874

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-06
    • 2017-09-15
    • 1970-01-01
    • 1970-01-01
    • 2012-03-09
    • 1970-01-01
    • 2015-12-27
    • 1970-01-01
    相关资源
    最近更新 更多