Override file upload sizes an htaccess file

David Carr

2 min read - 10th Oct, 2010

A tutorial to override file upload sizes an htaccess file. Note htaccess files only work on a linux server

By default you can only upload files up to 2MB in file size but this can be increased with an htaccess file.

To create an htaccess file open notepad or any plain text editor and save the file as .htaccess, if using notepad make sure the file type is set to all files or you will create a txt file.

start with php_value which tells the server to expect a rule to follow

To increase the file size that can be uploaded use the rule upload_max_filesize followed by the file size in mega bite (MB)

#set max upload file size
php_value upload_max_filesize 20M

You may also need to increase the max size that a form can send this is done using the rule post_max_size followed by the file size in mega bite (MB)

#set max post size
php_value post_max_size 20M

When uploading big files the server can time-out as there is a time limit for the data to be sent, This again can be increased using this rule max_execution_time followed by the time in seconds

#set max time script can take
php_value max_execution_time 200

You can increase the input time for the server using the rule max_input_time followed by the time in seconds

#set max time for input to be received
php_value max_input_time 200

The final file will look like this:

#set max upload file size
php_value upload_max_filesize 20M
#set max post size
php_value post_max_size 20M
#set max time script can take
php_value max_execution_time 200
#set max time for input to be recieved
php_value max_input_time 200

Save the htaccess file in the root of the server or in the directory where you want to override file upload sizes.

0 comments
Add a comment

Copyright © 2024 DC Blog - All rights reserved.