简体   繁体   中英

Unable to change upload_max_filesize to Azure

I have a Laravel Azure website.

I have a .user.ini file where I have some settings like

upload_max_filesize=120M
post_max_size=121M
output_buffering=Off
max_execution_time=3000
max_input_time=3000
memory_limit=140M

But, strangely enough, only max_execution_time and memory_limit changed . I also tried ini_set() but with the same result.

Is there a solution for this?

基本上我在设置 PHP_INI_SCAN_DIR 中添加了 .user.ini 文件夹路径的值

As PHP applications on Azure are actually hosted on IIS, so the limit upload file size is not only controlled by PHP settings but also by IIS configurations.

By default, the maximum length of content in a request is set 30000000 in IIS which is approximately 28.6MB. You can refer to https://www.iis.net/configreference/system.webserver/security/requestfiltering/requestlimits#005 for more details.

And beside custom configuration of PHP, you also need to create a web.config in your root directory, whose content can be the following sample:

<configuration>

    <appSettings/>
    <connectionStrings/>
    <system.web>
        <httpRuntime maxRequestLength="1073741824" />
    </system.web>
    <system.webServer>
    <security>
      <requestFiltering>
        <!-- maxAllowedContentLength is in bytes (B)  -->
        <requestLimits maxAllowedContentLength="1073741824"/>
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>
  1. Go to Azure Settings->Configuration

  2. Under 'Application settings', Click 'New Application settings' add following:

    Name: PHP_INI_SCAN_DIR

    Value: (whatever path, ex. d:\\home\\site\\ini)

  3. Open powershell, Go to Development Tools->Advanced Tools, Click 'Go ->'

  4. Open folder on the path you specify on #2 (ex. 'd:\\home\\site\\ini'). Then create .user.ini file

  5. Add the following:

    upload_max_filesize = 64M

    post_max_size = 64M

  6. Restart your server

You may check the values on your server using:

php -r "echo ini_get('upload_max_filesize');"

php -r "echo ini_get('post_max_size');"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM