Search code examples
phpuploadhttp-status-code-413

413 Error on PHP Video Upload on Windows Server with IIS


The video upload works fine with a 23 MB file, for example, but when I try a 38 MB file (or anything larger than that), after about 10 or 15 seconds, it fails with a 413 error.

I've modified my php.ini with the following settings:

memory_limit = 5000M
upload_max_filesize = 500M
post_max_size = 500M
max_input_time = 60

I've confirmed by looking at phpinfo.php that these settings are in effect.

I've also gone into IIS and increased the uploadReadAheadSize from 49152 to 491520000 bytes, and restarted the server.

The machine itself is running Windows Server 2016 with 32 GB of RAM.

All of these settings appear to be sufficient to upload a 38 MB file and yet I'm running into this error which tells me there's something else I need to check or adjust. I realize there are similar threads, but I've tried all the suggested solutions and still it doesn't work, so I need a different solution.

EDIT: My form looks like this.

<form id='upload_video_form' enctype='multipart/form-data' style='height:0px;margin:0px'>
<input type='file' style='display:none' accept='video/*' name='upload_video_file' id='upload_video_file' />
<input type=hidden name=upload_video_companyid value=".$companyid.">
<input type=hidden name=upload_video_childid id=upload_video_childid value='".$childid."'>
<input type=hidden name=upload_video_reportid id=upload_video_reportid value='".$mediaid."'>
</form>

Solution

  • The Webserver might define something like "client_max_body_size" (nginx) or "LimitRequestBody" (Apache) below that size.

    IIS setting, according to this article, is "maxAllowedContentLength"

    https://www.inflectra.com/support/knowledgebase/kb306.aspx

    PHP settings come only after the webserver...

    hth