By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,598 Members | 1,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,598 IT Pros & Developers. It's quick & easy.

How do I get the request limitation size in IIS via PHP?

P: n/a
Following is my function I wrote to retrieve the value of
LimitRequestBody in php.conf if the webserver is Apache:

There is no native method in PHP to obtain a value that is in a
separate CONFIG file, particularly
/etc/httpd/conf.d/php.conf, therefore, you will have to obtain it
yourself the hard way: splice up the
file and retrieve and set into a session variable, or, obtain from
the existing session variable
function &getLimitRequestBody() {
global $limitRequestBodyFilePath;
if ($_SESSION['limitRequestBody']) {
return $_SESSION['limitRequestBody'];
} else {
$fileID = @fopen($limitRequestBodyFilePath, 'r');
if (!$fileID) return 0; // BOMB OUT - $limitRequestBodyFilePath SET
$contents = @fread($fileID, filesize($limitRequestBodyFilePath));
preg_match('/LimitRequestBody[\s\t]*([0-9]+)\n*/i', $contents,
$_SESSION['limitRequestBody'] = (int)trim($matchArray[1]);
return (int)trim($matchArray[1]);

Nice function, however, HUGE dilemma: the application that will use
this function is designed to be fully portable, that is, it can run in
Apache or IIS or anything that can run PHP. That means everything in
this application needs to run equally in any webserver that can handle
PHP, including this function.

This function works only if you're using Apache since it retrieves a
specific file /etc/httpd/conf.d/php.conf that has a value I need that
PHP itself cannot provide to determine the absolute limit of a

So how do I write this for IIS or any other PHP-friendly webserver?

Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.