I've searched around, and I've found the string I need to add to my ".htaccess" or "php.ini" file in order to circumvent the 2MB file upload limit I currently have.

HOWEVER, this presupposes that I can *find* these files!
1) I can't find a php.ini file anywhere. Where should I look?
2) There are .htaccess files in several folders. Should I use the one in my subdomain (example.com/public_html/drupal, where I have Drupal), or on my main site (example.com)?
3) Which file is better to edit? Should I do both, or just one?
4) Where in particular do I add the string (assuming there is no comparable upload_max phrase in the file already)?

Yes, this is my fourth "help me, my technology skills are below the assumed Drupal entrance threshold" topic - sorry :-/

~Ethan

Comments

cog.rusty’s picture

Using php.ini or .htaccess are two alternatives. One of them is enough, assuming that it works.

php.ini is a file which you must take from your server, copy to your Drupal installation directory, and modify it by adding the two lines at the end. It is not certain where on your server you can find it. It may be in /usr/local/Zend/etc/php.ini or in /usr/lib/php.ini or in /usr/bin/php/php.ini or in /usr/local/lib/php.ini or in /usr/local/bin/php/php.ini or... You may need to ask your host. If your host supports this method, it will work for sure.

.htaccess can do that as well in most cases, and it is more accessible. You can use either the one in drupal, or the one in your web root, which will affect all subdirectories including drupal, or both. It doesn't matter much where you put the two lines in the file, you could put them right on the top. The syntax is slightly different from php.ini.

About the values you need to add, the php documentation says that for upload_max_filesize to work:
- post_max_size must be bigger that upload_max_filesize
- memory_limit must be bigger than post_max_size

There is also a Drupal limitation (by design) which won't let you upload a file bigger than half your post_max_size. So, to be able to upload 8M files you could use (for example):

In php.ini, at the end:

upload_max_filesize = 8M 
post_max_size = 16M 
memory_limit = 24M 

Or, in .htaccess, any place.

php_value  upload_max_filesize  8M
php_value  post_max_size  16M
php_value  memory_limit  24M 

To check if your changes with either method worked, you can upload and run a php file containing the line <?php phpinfo();> or you can install the http://drupal.org/project/systeminfo module.

If you have the upload module enabled (a core module), then you can also see what Drupal will allow in the /admin/settings/uploads page.

phsphoenix’s picture

Thank you very much! I have two MORE questions now... :-p

1) What does the "memory limit" do?
***2) Instead of clicking "Edit File," I actually deleted the .htaccess file from my server at one point! I restored it, but it was blank, without the Drupal code and info that had been there before. It doesn't seem to be affecting anything yet (though I had to reset the password on my cpanel)... anything I should do to get that back to how it was?

Thanks,
~Ethan

vm’s picture

1) What does the "memory limit" do?

increases the amount of RAM that can be used on the server. Doing so avoids blank screen apache errors.

2) anything I should do to get that back to how it was?

download another drupal package and upload the .htaccess file that comes with it.

___________________________________________________________
The search tool on Drupal.org really does work.
This message has been brought to you by:
the letter X , the letter Z and the number 2.
Thanks for watching! : )
cog.rusty’s picture

1. memory_limit sets the max php memory size that drupal can use on the server. On most servers that is set to 8M by default, which is not enough when you start installing modules, so changing to 24M or 32M or more is often necessary. See:

http://drupal.org/node/29268

2. Drupal's .htaccess file is included in the tar.gz package of your drupal version (a newer one will do as well). You can extract it from the drupal package, edit it with a plain text editor, and upload it to your drupal installation directory. Or get its content from here:

http://cvs.drupal.org/viewvc.py/drupal/drupal/.htaccess?revision=1.81.2....

--------------------------

If you want to understand better the background of all this, check this paragraph of the php manual:

http://www.php.net/manual/en/ini.core.php#ini.post-max-size

and also this handbook page about Drupal's behavior with these values:

http://drupal.org/node/97193

thambar’s picture

I try to adopt this solution. I modified php.ini increasing php_value -> upload_max_filesize 12M on my WAMP server.
Unfortunately it did not work and I received this message:

"PHP Startup: Unable to load dynamic library 'c:/wamp/bin/php/php5.3.0/ext/php_pdo_mssql.dll' - unable to find the specified module"

I reset the php.ini with original php value and now what I get is:

Fatal error: Undefined class constant 'MYSQL_ATTR_USE_BUFFERED_QUERY' in C:\wamp\www\vocportal\includes\database\mysql\database.inc on line 50

What can I do to fix this problem?

mmjvb’s picture

You are mixing the .htaccess syntax with the php.ini. The php_value syntax is for .htaccess. The php.ini is without the php_value !

The message about php_pdo_mssql is unrelated. Suggest to comment out that line, assuming you are using MySQL and NOT MSSQL.
Restart apache after changing php.ini to make the changes effective.
Doubt very much copying php.ini to your DocumentRoot will help. Not many servers are setup to recognize it in your root. Most respect .user.ini, check your phpinfo for user provided ini settings.

For the undefined constant either remove it or check the version of MySQL. Looks like it needs updating as well. Appears that this environment never worked instead of running into issues on working environment.

thambar’s picture

Found this in my php.ini

;;extension=php_pdo_mssql.dll

too many ; isn't it?

mmjvb’s picture

Tried on XAMPP but didn't see any error in the log. What kind of stack are you using (version of apache, php)?

thambar’s picture

WAMPSERVER 2.0
apache 2.2.11
php 5.3.0
Mysql 5.1.36

mmjvb’s picture

Those components are far too old. PHP 5.3.0 is just bad, never use that!

Ole Martin’s picture

Hi.
make a file named: "php-test.php" and put in your drupalroot-installasion.
In this file you put this code:

phpinfo();

and you will see your php.ini configurations.
----------------
In my .htaccess-file I have:
php_value upload_max_filesize 100M
php_value post_max_size 100M in the end of the file.
So now I can upload 100MB files.

Ole Martin
http://www.drupal.no
http://www.drupal1.no