【问题标题】:Is there a limit to filesize upload by chrome using ajax/put request?使用 ajax/put 请求通过 chrome 上传文件大小是否有限制?
【发布时间】:2018-11-20 13:13:11
【问题描述】:

以下是我用来将 1 分钟视频上传到服务器的 ajax PUT 请求。 文件由文件读取器读取。

它完全适用于 Firefox 和 Edge。 它适用于 Chrome,文件大小低于 106 兆字节

但是对于 175 兆字节的文件失败了

这是请求:

    $.ajax({
        url: urlToS3,
        type: 'PUT',
        cache: false,
        processData: false, 
        data: reader.result, //video file read using filereader
        async: true,  
        success: fnSuccess,
        error: fnError,
        crossDomain: true,

        contentType: false,
        xhr: function() {
                    xhr = new window.XMLHttpRequest();    //xhr is a global variable
                    xhr.upload.onprogress = function (evt){fnOnprogress(evt);} ;
                    xhr.upload.onload = fnOnload;
                    xhr.upload.onerror = fnOnerror; 
                    return xhr;
                  },
}, 'json');     //$.ajax({

测试:

chrome 失败:reader.result.byteLength= 183190491

chrome reader.result.byteLength= 127838343 成功

【问题讨论】:

    标签: javascript jquery ajax google-chrome xmlhttprequest


    【解决方案1】:

    我通过改变方法来解决问题。我不再使用 FileReader。我正在这样做:

        var file = document.getElementById('_testFile').files[0];
    
    $.ajax({
        url: "/attachmentURL",
        type: "POST",
        data: file,
        processData: false
    });
    

    });

    感谢:Posting File Input as FileReader Binary Data through AJAX Post

    【讨论】:

      猜你喜欢
      • 2023-04-07
      • 1970-01-01
      • 1970-01-01
      • 2022-08-09
      • 1970-01-01
      • 2010-12-27
      • 2012-02-21
      • 2010-12-01
      • 1970-01-01
      相关资源
      最近更新 更多