簡體   English   中英

使用 PHP 和 Ajax 上傳大電影 (>20MB)

[英]Uploading big movies (>20MB) using PHP & Ajax

我正在嘗試使用 Ajax 和 PHP 上傳 mp4 文件。 當文件大約 10MB 時一切正常,但如果文件更大(我嘗試使用 34MB)上傳器卡住並且文件不上傳。 JS:

    function _(el){
    return document.getElementById(el);
}
function uploadFile(){
    var file = _("file-upload").files[0];
var formdata = new FormData();
        formdata.append("file-upload", file);
        var ajax = new XMLHttpRequest();
        ajax.upload.addEventListener("progress", progressHandler, false);
        ajax.addEventListener("load", completeHandler, false);
        ajax.addEventListener("error", errorHandler, false);
        ajax.addEventListener("abort", abortHandler, false);
        ajax.open("POST", "/app/upload.php");
        ajax.send(formdata);
    }
}
function progressHandler(event){
var percent = (event.loaded / event.total) * 100;
_("progressBar").value = Math.round(percent);
_("status").innerHTML = Math.round(percent) + "%";
}

HTML:

<form id="upload_form" method="post" class="my-2" action="/app/upload.php" enctype="multipart/form-data">
<input id="file-upload" type="file" accept="video/mp4" name="file-upload" />

php.ini

max_execution_time = 3000
memory_limit = 256M
post_max_size = 100M
upload_max_filesize = 100M

如何允許用戶上傳“更大”的文件?

編輯我剛剛注意到,Chrome 控制台顯示:無法加載資源:net::ERR_CONNECTION_RESET 另外 - php 日志沒有顯示任何問題。 PHP 正在 IIS 服務器上工作

Ok, as it is PHP working on IIS direction it seems that except php.ini we need to change settings in web.config For posterity:

<system.web>
        <httpRuntime maxRequestLength="102400" />
    </system.web>
    <system.webServer>
        <security>
            <requestFiltering>          
                <!--The default size is 30000000 bytes (28.6 MB). MaxValue is 4294967295 bytes (4 GB)-->
                <!-- 100 MB in bytes -->
                <requestLimits maxAllowedContentLength="104857600" />
            </requestFiltering>
        </security>
</system.webServer>
</configuration>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM