`
touchinsert
  • 浏览: 1313933 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

FileUpload控件上传大文件

 
阅读更多

Uploading Large Files

You must do extra work when uploading large files. You don't want to consume all your server's memory by placing the entire file in memory. When working with a large file, you need to work with the file in more manageable chunks.

First, you need to configure your application to handle large files. Two configuration settings have an effect on posting large files to the server: the httpRuntime maxRequestLength and httpRuntime requestLengthDiskThreshold settings.

The maxRequestLength setting places a limit on the largest form post that the server will accept. By default, you cannot post a form that contains more than 4MB of dataif you try, you'll get an exception. If you need to upload a file that contains more than four megabytes of data, then you need to change this setting.

The requestLengthDiskThreshold setting determines how a form post is buffered to the file system. In the previous version of ASP.NET (ASP.NET 1.1), uploading a large file could do horrible things to your server. The entire file was uploaded into the server memory. While a 10-megabyte video file was uploaded, for example, 10 megabytes of server memory was consumed.

The ASP.NET 2.0 Framework enables you to buffer large files onto the file system. When the size of the file passes the requestLengthDiskThreshold setting, the remainder of the file is buffered to the file system (in the Temporary ASP.NET Files folder).

By default, the ASP.NET framework is configured to buffer any post larger than 80KB to a file buffer. If you are not happy with this setting, then you can modify the requestLengthDiskThreshold to configure a new threshold. (The requestLengthDiskThreshold setting must be less than the maxRequestLength setting.)

The web configuration file in Listing 4.4 enables files up to 10MB to be posted. It also changes the buffering threshold to 100KB.

Listing 4.4. Web.Config

<?xml version="1.0"?>
<configuration>
<system.web>
<httpRuntime
maxRequestLength="10240"
requestLengthDiskThreshold="100" />
</system.web>
</configuration>
分享到:
评论

相关推荐

    用FileUpload控件上传文件到数据库

    #### 使用FileUpload控件上传文件 下面通过具体的代码示例来说明如何使用ASP.NET中的`FileUpload`控件实现文件上传功能。 ```csharp try { string name = FileUpload1.FileName; // 获取上传文件的名称 string ...

    .net使用FileUpLoad控件上传文件

    ### .NET 使用 FileUpload 控件上传文件 在 ASP.NET Web 应用程序中,经常需要实现文件上传功能,这可以通过使用 `FileUpload` 控件来完成。本文将详细介绍如何使用 `.NET` 中的 `FileUpload` 控件进行单个文件的...

    fileupload控件上传图片和附件

    在IT领域,特别是Web开发中,...通过以上解析,我们可以看出,利用FileUpload控件上传图片和附件的过程虽然看似简单,但涉及到了多个关键的技术点。正确理解和应用这些技术,可以显著提升Web应用程序的功能性和安全性。

    FileUpload控件自动上传

    在.NET框架中,FileUpload控件是用于处理用户在Web应用程序中上传文件的关键组件。它允许用户选择本地计算机上的文件,并将其发送到服务器进行进一步处理。在这个特定的场景中,我们关注的是FileUpload控件的自动...

    fileupload控件的使用

    同时,我们也可以使用 FileUpload 控件来上传多个文件,例如使用多个 FileUpload 控件或使用单个 FileUpload 控件上传多个文件。 FileUpload 控件提供了一个简单的方式来上传文件,并且可以对上传的文件进行验证和...

    ASP.NET使用fileupload控件上传图片

    ### ASP.NET 使用 FileUpload 控件上传图片的知识点详解 #### 一、概述 在ASP.NET Web应用程序中,经常需要处理用户上传的文件,尤其是图片。本文将详细介绍如何使用ASP.NET中的`FileUpload`控件来实现图片的上传...

    FileUpload控件上传文件客户端验证格式

    综上所述,FileUpload控件的客户端验证是Web应用中必不可少的一环,它结合了JavaScript、jQuery和HTML5等技术,确保了用户上传文件的安全性和合法性。同时,服务端验证作为补充,为整个文件上传过程提供了额外的安全...

    ASP.NET.FileUpload控件

    应限制上传文件的类型和大小,防止恶意文件如病毒或脚本文件的上传。你可以使用`ContentType`属性检查文件类型,或使用`FileSizeLimit`属性设置文件大小限制: ```csharp if (FileUpload1.HasFile && FileUpload1....

    C#通用文件上传类(页面所有FileUpload控件中文件)

    2. **验证并上传文件**:对于找到的每个FileUpload控件,我们需要检查文件大小、类型等,确保上传的文件符合服务器的限制。接着,可以使用`SaveAs`方法将文件保存到服务器指定的目录。 ```csharp private static ...

    使用FileUpload控件上传图片并自动生成缩略图、带文字和图片的水印图

    在ASP.NET中,FileUpload控件是用于处理用户上传文件的一种常见方式。在这个场景中,我们看到一个简单的ASP.NET页面,它包含一个FileUpload控件让用户选择图片文件,以及一个Button控件触发上传操作。当用户点击...

    C#Fileupload上传控件上传任意大小的文件

    综上所述,使用C#的FileUpload控件上传任意大小的文件,需要配置`Web.Config`以提高上传限制,同时在服务器端编写代码来处理大文件。提供的“利用C#Fileupload上传控件上传任意大小的文件.txt”文档应该包含更详细的...

    Asp.net 2.0 用FileUpload 控件实现多文件上传

    在Asp.net 2.0框架中,FileUpload控件是用于处理用户上传文件的核心组件。这个控件允许用户从他们的计算机选择一个或多个文件,然后将这些文件上传到服务器。在本文中,我们将深入探讨如何利用FileUpload控件实现多...

    一个漂亮的fileupload控件

    "一个漂亮的fileupload控件"这个标题所指的,就是一种优化了上传文件功能的UI组件。FileUpload控件是网页表单中常见的一种元素,它允许用户选择本地计算机上的文件并将其上传到服务器。在这里,描述提到这个控件是...

    11.文件上传FileUpload 控件

    文件上传 FileUpload 控件,分享

    net使用FileUpLoad控件上传文件.

    ### .NET 使用 FileUpload 控件上传文件 在 Web 开发中,经常需要处理用户上传的文件,例如图片、文档等。.NET 框架提供了一个非常方便的控件——`FileUpload`,用于实现文件的上传功能。下面将详细介绍如何在 ASP...

    ASP.Net中FileUpLoad控件

    FileUpload控件是ASP.NET提供的用于处理用户上传文件的一个服务器控件。它允许用户选择本地计算机上的文件,并将其上传到服务器。FileUpload控件非常易于使用,只需要简单的设置即可完成文件上传功能。 **基本语法...

    【ASP.NET编程知识】asp.net fileupload控件上传文件与多文件上传.docx

    ASP.NET中的FileUpload控件是用于用户在网页上选择并上传文件到服务器的关键组件。它在ASP.NET编程中扮演着重要角色,特别是在处理用户需要提交本地文件到服务器的应用场景下,如图片上传、文档共享等。 在提供的...

    asp.net fileupload控件上传文件与多文件上传

    在***开发中,文件上传是常见的功能之一,通过fileupload控件,开发者可以实现用户界面上传文件到服务器端的逻辑。本篇文档详细介绍了fileupload控件的基本用法,如何进行单文件上传以及如何实现多文件上传,以及...

    Anthem.NET中FileUpload控件Ajax方式的文件上传

    在本文中,我们将深入探讨如何在Anthem.NET 1.5框架中利用FileUpload控件实现Ajax方式的文件上传。Ajax(异步JavaScript和XML)技术允许我们在不刷新整个页面的情况下更新部分网页内容,从而提供更好的用户体验。...

Global site tag (gtag.js) - Google Analytics