如何获得客户端邮件大小?

时间:2017-08-23 04:37:16

标签: javascript php handsontable

我想问一下,如何获取我作为客户端传递给服务器的数据大小。在开发应用程序时,我无法在服务器端获取整个数据。我的POST限制大小在服务器端是6M,如php.ini文件。

我之前已经问了一个类似的问题(How to parse large data via POST query),但没有得到及时答复。

由于

2 个答案:

答案 0 :(得分:1)

试试这个:

$data_size = (int) $_SERVER['CONTENT_LENGTH'];

答案 1 :(得分:0)

请在提交表格上使用此功能

<button onclick="store()" type="button">form submit</button>

function store(){     
    var totalsize = 0;    // total post data size
    $('form').find('input[type=file]').each(function() { // for all files in form
        totalsize += this.files[0].size;
    });

    totalsize=totalsize+($("form").not("[type='file']").serialize().length);

    if (totalsize > (6 * 1048576)) { // > 6MB   
        // this will exceed post_max_size PHP setting, now handle...

        alert('this will exceed post_max_size PHP setting')
    } else if ($('form').find('input[type=file]').length >= 10) { // max_file_upload_limit = 10; 
        // if file upload is more than 10
         alert('upload is more than 10 files')
    }else{

      you are free upload data successfully
    }
}
相关问题