Large File Http Post Upload - PHP and ASP.net

To upload large files to web server, the developers need to modify some settings in the php or asp.net program.

By default, PHP permits a maximum file upload of 2MB. So it's necessary to increase the limit when necessary.

Two PHP configuration options control the maximum upload size: upload_max_filesize and post_max_size. Both can be set to, say, "20M" for 20 megabyte file sizes.

However, you also need to consider the time it takes to complete an uploading. PHP scripts normally time-out after 30 seconds, but a 20MB file would take at least 5 minutes to upload on a healthy broadband connection. In addition, manipulating or saving an uploaded office file may also cause script time-outs. We therefore need to set PHP's max_input_time and max_execution_time to something like 300 (5 minutes specified in seconds).

These options can be set in your server's php.ini configuration file so that they apply to all your applications. Alternatively, if you're using Apache, you can configure the settings in your application's .htaccess file:

php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_input_time 300
php_value max_execution_time 300

Finally, you can define the constraints within your PHP application:

ini_set('upload_max_filesize', '20M');
ini_set('post_max_size', '20M');
ini_set('max_input_time', 300);
ini_set('max_execution_time', 300);

Setting the options in your PHP code is possibly more practical, since you can extend the execution time and increase the file size when your application is expecting a large uploading.

For asp.net program, you need config the web.config.

The following attributes can be assigned to the <httpRuntime> tag in the <system.web> section of the Web.config file.

1. maxRequestLength : Specifies the limit for the input stream buffering threshold, in KB. This limit can be used to prevent denial of service attacks that are caused, for example, by users posting large files to the server. The default value is 4096 (4 MB). To enable large file uploads you need to change the value of this attribute to the largest allowed combined file size for your application. If someone selects and uploads files with total size larger than maxRequestLength, this will result in a "Page not found" error (which is the default error of the Framework).

2. executionTimeout : Specifies the maximum number of seconds that a request is allowed to execute before being automatically shut down by ASP.NET. The value of this setting is ignored in debug mode. The default in .NET Framework 2.0 is 110 seconds. In the .NET Framework 1.0 and 1.1, the default is 90 seconds.

To enable large file uploading, which can take long periods of time, increase the value of this property (executionTimeout).

For example: The configuration, allowing uploading of files up to 100MB and uploading periods up to 1 hour, should looks like the followings:

<?xml version="1.0"?>
<httpRuntime maxRequestLength="102400" executionTimeout="3600" />
<compilation debug="true" targetFramework="4.0"/>
<authentication mode="Windows"/>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
<security >
<requestLimits maxAllowedContentLength="1024000000" />

Http Open File From Stream

FTP Upload Download Office Files

Disables Office 2003 Toolbars

Disable Office Ribbon Button

Show/Hide Office Menu Bar

Integrate MS Office in Delphi Program

Embed Office in C# and Do Office Automation

Embed MS Office in WPF Program

Office ActiveX Control

Get Started! Make your application display and interact with MS Office. Try Office Viewer Component