-1

I am using phpUploader on IIS8.5. I have the php upload set to 20mb and I have the site set to:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <security>
            <requestFiltering>
                <requestLimits maxAllowedContentLength="30000001" />
            </requestFiltering>
        </security>
    </system.webServer>
</configuration>

I tried to upload a file larger than allowed, approx 50mb, and instead of php grabbing it, IIS gave me an error.

Here is the check in the phpUploader.php:

// Max size PER file in KB
$max_file_size="20000";

// Max size for all files COMBINED in KB
$max_combined_size="80000";
//Check the size of each file
} Elseif($_FILES['file']['size'][$i] > ($max_file_size*1024)) {
   $error.= "<b>FAILED:</b> ".$_FILES['file']['name'][$i]." <b>REASON:</b> File to large.<br />";

I have this set in php.ini:

upload_max_filesize = 100M

How do I prevent IIS from erroring out before php gets to it to verify the file size?

Andrew Schulman
  • 8,561
  • 21
  • 31
  • 47
ErocM
  • 252
  • 7
  • 22
  • Why the downvote!? – ErocM Mar 23 '15 at 12:16
  • You don't. IIS is first, if the upload is too big for IIS the request doesn't even get to PHP. increase the IIS limit above your PHP limit. – Peter Hahndorf Mar 23 '15 at 12:50
  • @PeterHahndorf It's already is buy a good amount. I will increase it more so it doesn't hit it. Thanks for the info. Give me this as an answer and I give you the accept. – ErocM Mar 23 '15 at 13:35
  • Still would like to know why I got a downvote... – ErocM Mar 23 '15 at 13:36
  • @ErocM If you hover over the down arrow, it will tell you the reason for the downvote. Sometimes a voter will give additional information in a comment, but not always. And they won't see your comments asking for them to do so; there's no mechanism to inform someone of a comment made on a post they've downvoted. – Jenny D Mar 24 '15 at 09:50

1 Answers1

2

Any limitation imposed by IIS are processed first, before application frameworks like PHP are involved. If IIS decides the request is too big, it stops the request pipeline and returns an error without ever invoking PHP.

If you want to handle the file too large error in your code you can try to set the IIS limit very high. But if someone posts a even larger file, the IIS error will still kick in.

Peter Hahndorf
  • 13,763
  • 3
  • 37
  • 58