3

I have a single PHP script on a single site that requires me to set the upload size maximum fairly high. I would prefer not to do this globally.

According to the PHP docs, I can not set the values for some variable such as post_max_size , max_file_uploads or upload_max_filesize using ini_set. I've seen a number of solutions here running PHP on a UNIX box or on Windows running Apache, but none that are clear to me using IIS.

My understanding is that there is a way for me to have a custom php.ini file to override specific php.ini value.

Ideally, I would love to have a php.ini file in the folder with that one script that looks something like this:

[PHP]
post_max_size = 200M
max_file_uploads = 5
upload_max_filesize = 200M

How can I accomplish this without setting the values globally on my server?

hakre
  • 193,403
  • 52
  • 435
  • 836
Ralph M. Rivera
  • 769
  • 3
  • 12
  • 25
  • Not sure about IIS, but on an Apache server, you can specify settings in a .htaccess file. Example: `php_value upload_max_filesize 32M` – Nadh Apr 26 '12 at 16:21
  • @Brad ; good question: How do I determine that? – Ralph M. Rivera Apr 26 '12 at 16:25
  • @Brad I have CGI installed and in the root of IIS, I have "FastCGI Settings" panel. – Ralph M. Rivera Apr 26 '12 at 16:30
  • @HumanBacon, How did you set up PHP? When you installed PHP, you would have set it up one way or the other. The reason I ask, is if I remember correctly, you can specify a different command line to run scripts for different sites. If that is the case, you can specify the different INI file on the command line. `phpinfo()` may tell you, but if I remember correctly, it just says CGI/FastCGI, rather than one or the other. It's been awhile since I've used IIS... I don't completely remember. – Brad Apr 26 '12 at 16:39
  • 1
    @HumanBacon, Hmmm, sorry, I don't know how to do this with FastCGI. I'm sure it's possible though. Hopefully someone else knows the answer. You might consider moving this question over to ServerFault.com. – Brad Apr 26 '12 at 16:51

1 Answers1

0

You can set a seperate ini file for each website using the PHPRC environment variable as stated here http://php.net/manual/en/configuration.file.php.

And here is an article on how to set it for IIS 6 and 7.

http://learn.iis.net/page.aspx/745/enable-per-site-php-configuration-on-iis-60-and-iis-7-and-above/

Hope this helps

Patrick Forget
  • 2,143
  • 1
  • 18
  • 20