Your PHP settings limit the maximum file size per upload to 4 MB

henwoodr - January 16, 2007 - 22:11

In my file upload settings section it says "Your PHP settings limit the maximum file size per upload to 4 MB". What file exactly would i have to edit to fix this to a higher limit? Thanks for any help guys. (im still new to this :) )

You have to edit your

Algirdas - January 16, 2007 - 22:20

You have to edit your php.ini file. Or ask your system administrator to do that for you.

I have GoDaddy as my web

henwoodr - January 16, 2007 - 22:58

I have GoDaddy as my web hosting company right now. So your saying they have to change this file?

Godaddy Hosting as well as others maybe :D

dobe - July 24, 2009 - 22:37

OK this may help some noobs as well as the experienced:

For godaddy if you are using php 5 for your website you NEED to change the php.ini file to php5.ini that is located in your base directory. Or create a php5.ini file with the following values:

memory_limit = 96M
post_max_size = 64M
upload_max_filesize = 64M

Second you need to add the following values to the .htaccess file that comes pre packaged with Drupal in your base directory:

memory_limit = 96M
post_max_size = 64M
upload_max_filesize = 64M

Third you need to add to the following code to settings.php file that is located in /sites/default/:

ini_set('meemory_limit', '96M');
ini_set('post_max_size', '64M');
ini_set('upload_max_filesize', '64M');

As you can see the php values are virtually the same with different syntax.

Hope this helps

=-=

VM - July 24, 2009 - 22:47

Curious as to why this is being changed in 3 ways. It should only need to be changed once. If you have access to custom php.ini thats the only place you need to change it.

What you've done is now made it that much more difficult to make another change without changing 3 different files and that seems unnecessary.

If you don't have access to

cog.rusty - January 16, 2007 - 22:58

If you don't have access to php.ini, there are two place where you could possibly change the limit, depending on your host's setup.

In your settings.php file:

ini_set('post_max_size', '8M');
ini_set('upload_max_filesize', '8M');

In your .htaccess file:

php_value post_max_size 8M
php_value upload_max_filesize 8M

In my case the second one worked.

using a custom php.ini file

VM - January 17, 2007 - 00:13

using a custom php.ini file may also be an avenue for exploration.

This would mean getting a copy of the servers default php.ini, changing necessary values then uploading the php.ini file into your drupal installation. Doing it this way preserves the default settings for other sites/programs you have installed, and only allows the overides to happen for your drupal installation.

see http://drupal.org/node/29268 for more information.

I have looked into the files

henwoodr - January 17, 2007 - 00:28

I have looked into the files and my settings.php file (site.com/forum/sites/default/settings.php) did not have the values you show so i tried to add them and that didnt work.

I have 2 .htaccess files (site.com/forum/.htaccess) and (site.com/forum/files/.htaccess), neither have the values you show.

I am so lost :(

Add them in your first

cog.rusty - January 17, 2007 - 01:02

Add them in your first .htaccess file (the big one in Drupal's directory) near the top. Then check your /admin/settings/uploads again to see if your limit changed.

I added the values to the

henwoodr - January 17, 2007 - 02:22

I added the values to the best spots i could see but it didn't work. Here is the exact text i have. Maybe you could look it over and let me know if i did it right?

#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.

Order allow,deny

# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

# Customized error messages.
ErrorDocument 404 /index.php

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.

# PHP 4, Apache 1.

php_value post_max_size 100M 0
php_value upload_max_filesize 100M 0
php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0

# PHP 4, Apache 2.

php_value post_max_size 100M 0
php_value upload_max_filesize 100M 0
php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0

# PHP 5, Apache 1 and 2.

php_value post_max_size 100M 0
php_value upload_max_filesize 100M 0
php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0

# Requires mod_expires to be enabled.

# Enable expirations.
ExpiresActive On
# Cache all files for 2 weeks after access (A).
ExpiresDefault A1209600
# Do not cache dynamically generated pages.
ExpiresByType text/html A1

# Various rewrite rules.

RewriteEngine on

# If your site can be accessed both with and without the prefix www. you
# can use one of the following settings to force user to use only one option:
#
# If you want the site to be accessed WITH the www. only, adapt and
# uncomment the following:
# RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
# RewriteRule .* http://www.example.com/ [L,R=301]
#
# If you want the site to be accessed only WITHOUT the www. prefix, adapt
# and uncomment the following:
# RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
# RewriteRule .* http://example.com/ [L,R=301]

# Modify the RewriteBase if you are using Drupal in a subdirectory and
# the rewrite rules are not working properly.
#RewriteBase /drupal

# Rewrite old-style URLs of the form 'node.php?id=x'.
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{QUERY_STRING} ^id=([^&]+)$
#RewriteRule node.php index.php?q=node/view/%1 [L]

# Rewrite old-style URLs of the form 'module.php?mod=x'.
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{QUERY_STRING} ^mod=([^&]+)$
#RewriteRule module.php index.php?q=%1 [L]

# Rewrite current-style URLs of the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

# $Id: .htaccess,v 1.81 2007/01/09 09:27:10 dries Exp $

I just put them once at the

cog.rusty - January 17, 2007 - 04:04

I just put them once at the top, but I don't think it matters.

Why did you put the zeros at the end?

Well the zeros where there

henwoodr - January 18, 2007 - 00:30

Well the zeros where there already when i opened the file in a .htaccess editor. But its still not working. Im about to give up on this.

have you asked your host, if

VM - January 18, 2007 - 00:49

have you asked your host, if you are allowed to use a custom php.ini file ? checking their documentation may proove fruitful. They may have a knowledge base as well, or a forum to help you.

you could use a script to pull the default php.ini file and than change the values to what you need.

there is a scrpt of this nature here http://tips-scripts.com/ that may help you get your hands on the php.ini file. you will have to use the one from your server, as the can be server specific. In other words, giving you my custom php.ini file could cause you problems so its best to get it directly from your server.

php.ini

gadzuk - February 7, 2007 - 03:41

Adding the following lines both to php.ini in my Drupal directory and settings.php worked for me

post_max_size = 8000000
upload_max_filesize = 8000000

php.ini

Nexus5.01 - June 9, 2008 - 20:11

Worked fine for me, I'm using HostGator as my host for reference :)

Thanks!

Make sure the php.ini is in the root of the Drupal installation - just incase!

Worked for me on a 1and1 server

viktor.mastoridis - December 2, 2008 - 02:02

Thanks a lot, after 2 hours of frustrations, this tip worked, on a 1and1 server.

Actually, in more detail (for 800mb limit):

php.ini file:
post_max_size = 800000000
upload_max_filesize = 800000000

settings.php:
ini_set('post_max_size', '800000000');
ini_set('upload_max_filesize', '800000000');

Note that you are also

cog.rusty - December 2, 2008 - 09:00

Note that you are also limited by your php memory_limit. See what http://php.net/ini.core says about post_max_size.

This means that with a memory_limit of 64M, a single POST operation in a node editing form can upload less than that.

So, when people need to upload very large files they often use tools which partly bypass PHP's uploading method, for example with Flash, like http://drupal.org/project/swfupload which can upload up to 2G files.

Thanks

sjohnston - May 3, 2009 - 20:49

That was the perfect solution for me.

Thanks

Treesong - January 22, 2010 - 18:20

Thank you for your post! Writing out the zeroes instead of using an M is what did the trick for me. People should NOT be giving out advice which uses an M in place of six zeroes because that doesn't seem to work.

=-=

VM - January 23, 2010 - 01:35

Likely depends on what file you worked with. PHP.ini is distributed using M, for example.

For Dreamhost

rosshj - August 21, 2009 - 22:08

http://www.activecollab.com/forums/topic/1507/

If that doens't work, here's an easier method.

http://sxi.sabrextreme.com/forum

Just register to the forum, download the Ioncube script, run it over URl
and you're set.

-
Ross Howard-Jones
User Interface Designer
rosshj.com
Donat Group Enterprises
Project Opus

I don;t know why, but I just

Rskennan - February 23, 2008 - 15:17

I don;t know why, but I just found that:

post_max_size = 20
upload_max_filesize = 20

Didn't work.

Instead, I tried:
post_max_size = 100
upload_max_filesize = 20

Since I reasoned that maybe the overall post size had to be larger than the max upload size.

Whether my logic was right or wrong, it worked.

Good luck to anyone else who has this problem.

file upload max size

leop - February 26, 2008 - 21:34

In the Drupal API I find that post_max_size is divided by 2, as sanity check. It says it does it only for 4.7, but when I look at the 5.7 code that is installed at my website, it still uses the divide by 2 factor:

<?php
// sanity check- a single upload should not be more than 50% the size limit of the total post
   
$post_max = _file_convert_to_mb(ini_get('post_max_size')) / 2;
?>

The API doc probably meant

cog.rusty - February 27, 2008 - 04:18

The API doc probably meant that the division by 2 was first introduced in Drupal 4.7. It was removed from Drupal 6 on 8-Oct-2007 and from Drupal 5 on 11-Feb-2008, as you can see here:

http://drupal.org/node/104220

Drupal 5.7 was released on 28-Jan-2008, so the change has not made it into a release yet. You could look at the last patch and fix it yourself, by removing the two '-' lines and adding the '+' line in includes/file.inc.

=-=

VM - February 27, 2008 - 04:19

or download the -dev version of drupal which will be come 5.8

Had this same problem in 6.0

JoshuaB86 - March 4, 2008 - 20:15

I made a file called php.ini in notepad

I then put these two lines in it:

post_max_size = 100000000000
upload_max_filesize = 100000000000

that fixed it.

This

Twelvizm - February 2, 2010 - 09:32

Just wanted to bump the solution that worked for me. So simple, so easy.

Forcing PHP5 negates php.ini effect

sypl - October 24, 2008 - 09:07

I discovered something whilst trying to up my max upload limit. On my server, if you force PHP5 via .htaccess, then php.ini no longer has any effect.

My server runs PHP4 by default and I had to add the line at the end of .htaccess to force it to run PHP5 for Drupal:
SetEnv DEFAULT_PHP_VERSION 5

However, after doing this any instructions I put in the php.ini I placed in the root of my drupal install were ignored. Well, not ignored - they changed the settings for PHP4, but not for PHP5.

Does anyone know of a way around this problem?

php5.ini

sypl - October 24, 2008 - 09:48

Apparently renaming php.ini to php5.ini does the trick!

tried all these with no luck

cazam - December 30, 2008 - 12:56

Hi there,

I've tried all the above solutions with no luck. Am breaking my head on this one. I did it before when I was on 1and1 but migrated to bluehost (thanks credit crunch) and having nightmares.

First of all no php.ini so I had to install this. Fine. Installed it in the root and also copied to me site root (as I have a couple of sites).
I added:
php_value upload_max_filesize = 20M
php_value post_max_size = 40M

To both php.ini and no luck

Also tried changing hta access as mentioned in this thread http://drupal.org/node/97193
But it broke my site so had to quickly revert back.

Tried to add the lines to settings.php in the sites root folder also but no luck.

I am on PHP 5 & Drupal 6 and going bonkers - can anyone please hep???

CAZAM

For the values that you are

cog.rusty - December 30, 2008 - 14:05

For the values that you are using, you must have a memory_limit at least 64M.

If you added the "php_value ..." lines in a php.ini file, they are wrong. The syntax beginning with "php_value" is only for .htaccess files. See the examples.

Run a phpinfo() in a drupal page (see http://drupal.org/node/59680) to check whether your settings for memory_limit, post_max_size and upload_max_filesize work or not.

Check for any limit in Drupal's settings in admin/settings/uploads (if you are using the core upload module) or in the settings of the module that you are using for your uploads.

scared of the phpinfo page

cazam - December 30, 2008 - 14:22

hi again,
thanks for the response!
I checked the php.ini files and confirm that I had the following:
post_max_size = 40M
upload_max_filesize = 20M
Without the silly extra code I pasted in the above thread.

I am a bit scared of this phpinfo file as it says on the thread you gave me that it can break the formatting of the site. I know it will revert back, but, isn;t there a less frightening way?

I've checked with the host and they say change it to 200M is fine and the servers will just use as much memory as they have available.

Another way to run phpinfo()

cog.rusty - December 30, 2008 - 14:29

Another way to run phpinfo() and check if your settings work is to create a phpinfo.php text file, containing <?php phpinfo() ?>, upload it to Drupal's directory, and browse it.

Change what to 200M? The memory_limit? Then try it. At this moment it may be only 8M.

got it - 32MB

cazam - December 30, 2008 - 15:19

ahhh you are a genius, I did this and the memory limit is indeed only 32MB

sooo... in theory... if I change php.ini to read:

post_max_size = 32M
upload_max_filesize = 16M

then it may work?

Its not really big enough for what I need, but I guess that is a debate with the host.

Thanks again!

php info great but...

cazam - December 30, 2008 - 15:21

php info does read
post_max_size = 40M
upload_max_filesize = 20M

And also memory_limit = 32M

But then I am not too sure why when I go to the file upload box in drupal it says:
The maximum upload size is 1 MB.

This doesn't correspond with any of the numbers in the phpinfo

The 1MB limit is a Drupal's

cog.rusty - December 30, 2008 - 15:30

The 1MB limit is a Drupal settings in admin/settings/uploads (if you are using the core upload module), or in the settings of the module that you are using for your uploads.

The 32M memory_limit may be a limit from your host, but maybe not and you just need to set it. Do you have a memory_limit setting in your php.ini? (or in your .htaccess or in drupal's settings.php). if not, try:

memory_limit = 64M
post_max_size = 40M
upload_max_filesize = 39M

and check again what phpinfo() says.

tricky on the 1mb part

cazam - December 30, 2008 - 16:31

as I am trying to do a podcast, which I have done via adding a taxonomy term Podcast Item and then added terms to this taxonomy for each DJ and thus each podcast, I cannot find anywhere in taxonomy or any of these terms I added to change the file upload limit from 1MB.

I also looked at the general File Uploads settings and these are set to 100MB and 1000MB although it tells me my phpinfo limit is 20M which I already know as you kindly helped me set and check this.

I'm trying the memory limit settings above now but still unsure how to alleviate the 1MB upload problem within the Podcast Item taxonomy.

...thanks for being so patient with me!!!

increased the memory limit

cazam - December 30, 2008 - 16:34

ah you are so clever! I increased the memory_limit in the php.ini as you said and now - voila - it is 64MB

BRILLIANT

Now just that pesky little 1MB limit that is somehow attached to the taxonomy term Podcast Item I created...

Which module are you using

cog.rusty - December 30, 2008 - 16:52

Which module are you using to upload the podcasts?

If the 1M size limit is not in the settings of the upload module included in core, then it must be in the settings of some other file-handling module.

taxonomy

cazam - December 30, 2008 - 17:43

using taxonomy module
created a taxonomy called Podcast Items
And then I have items within that which are the DJs

Its probably staring me straight in the face but it seems to keep eluding me!

Taxonomy does not upload

cog.rusty - December 30, 2008 - 18:10

Taxonomy does not upload files. The file size setting is in some other module, such as upload, filefield, imce...

I'll keep hunting

cazam - December 30, 2008 - 21:38

it has to be in there somewhere...

found it!

cazam - December 30, 2008 - 22:22

thanks so much for all your help. In the end it was a simple case of re-entering values in the file uploads page and the refresh did the job!
thanks again

Upload

cviga - January 29, 2009 - 05:13

You must to edit settings.php in /sites/default/settings.php
add this lines

ini_set('post_max_size', '800000000');
ini_set('upload_max_filesize', '800000000');

and edit php.ini

post_max_size = 800000000
upload_max_filesize = 800000000

When you finish that restart wamp or xamp... its work... default upload limit is 762 MG

increase php upload limit

SkyChew - September 4, 2009 - 05:53

i am using Drupal on WAMP on a local machine.
you can edit the php.ini and restart the service for the wamp.

or you can edit the upload limit size increase just for the site without adjusting the global php.ini
i tried the settings.php method and a php.ini in the local folder method. both didnt work.
editing the .htaccess works for me

just added these 2 lines in the root .htaccess
php_value post_max_size 20M
php_value upload_max_filesize 10M
find this code and add the 2 lines of code in

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
.
.
.
  php_value post_max_size 20M
  php_value upload_max_filesize 10M
</IfModule>

my memory_limit is by default 128M as seen in phpinfo();

hope this helps

a simple solution that worked for me

zinasahib - November 23, 2009 - 19:57

Hi,
I ran into the same problem, and tried editing the settings and php.ini files with no success,
Then I noticed there is an entry in the php.ini file:

under : File Uploads:

upload_max_filesize = 2M;

I simply changed it to 20M and it works now!

MOSSO hosting didnt let me

jaykali - January 12, 2010 - 16:09

MOSSO hosting didnt let me change the settings from ini_set() but when I modifed .htaccess with the settings you provided, that worked for me - thx!

restart apache

vladislavbezruchenko - February 5, 2010 - 08:42

after changes in php.ini make

apachectl restart

to restart Apache on U'r linux server

 
 

Drupal is a registered trademark of Dries Buytaert.