【Web應用-大文件部署】上傳超過 2M 的文件到 Azure PHP 網站失敗

問題描述

上傳超過 2M 的文件到 Azure PHP 網站失敗。php

問題分析

因爲 PHP 自己默認上傳文件的上限是 2M,因此當上傳超過2M的文件時會報錯。web

解決方法

根據如下步驟進行配置:windows

  1. 在 site -> wwwroot 目錄下增長一個 .user.ini 文件,設置以下:app

     
    upload_max_filesize = 40M
    post_max_size = 40M
    Note

    以上兩個參數的值能夠根據需求自行修改。post

    爲了檢查配置是否成功也能夠在 .user.ini 文件中開啓 PHP log ,配置以下:網站

     
    display_errors = on
    log_errors = on 
    error_reporting = E_ALL
    error_log = D:\home\site\wwwroot\php.log
    file_uploads = on
  2. 因爲 IIS 默認請求體的大小爲 28.6M,若上傳的文件超過這個大小,還須要在 web.config文件中修改 IIS 請求體的大小,具體修改能夠參照下面的例子:.net

     
    <configuration>
    <system.webServer>
        <security>
            <requestFiltering>
                    <requestLimits maxAllowedContentLength="300000000"/>
            </requestFiltering>
        </security>
    </system.webServer>
    <system.web>
                    <httpRuntime maxRequestLength="300000000" appRequestQueueLimit="100" useFullyQualifiedRedirectUrl="true" executionTimeout="600"/>
    </system.web>
    </configuration>
  3. 作完上述的配置以後,建議在管理門戶重啓網站。code

參考連接

Windows Azure Web Sites: File upload limit for PHP sites hosted on WAWS
Request Limitsserver

 

當即訪問http://market.azure.cnblog

相關文章
相關標籤/搜索