Get size of POST-request in PHP

后端 未结 5 2066
遥遥无期
遥遥无期 2020-11-28 15:55

Is there any way to get size of POST-request body in PHP?

5条回答
  •  死守一世寂寞
    2020-11-28 16:33

    If you're trying to figure out whether or not a file upload failed, you should be using the PHP file error handling as shown at the link below. This is the most reliable way to detect file upload errors:
    http://us3.php.net/manual/en/features.file-upload.errors.php

    If you need the size of a POST request without any file uploads, you should be able to do so with something like this:

    $request = http_build_query($_POST);
    $size = strlen($request);
    

提交回复
热议问题