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.
For the past 12 years, I’ve been developing applications for the web using mostly PHP. I do this for a living and love what I do as every day there is something new and exciting to learn.
In my spare time, the web development community is a big part of my life. Whether managing online programming groups and blogs or attending a conference, I find keeping involved helps me stay up to date. This is also my chance to give back to the community that helped me get started, a place I am proud to be apart of.
Besides programming I love spending time with friends and family and can often be found together going out catching the latest movie, staying in playing games on the sofa or planning a trip to someplace I’ve never been before.