简体   繁体   English

如何获取发布到php的二进制数据的大小?

[英]How to get the size of a binary data posted to a php?

My 3rd party app creates an image and store it in a variable and then post it to a php on the server. 我的第三方应用程序创建图像并将其存储在变量中,然后将其发布到服务器上的php中。 for security matters, I need to limit the upload size. 为了安全起见,我需要限制上传大小。 Now that the binary data is not written to a file yet, how would I go around getting its size? 现在,二进制数据还没有写入文件,我该如何解决它的大小?

Here is the code: 这是代码:

<?php

$_data = $_POST['data']; //get the binary data from the client side.

    if($_data !=""){
       $handle = fopen($_path."/".$_ref.".png", "w");
       fwrite($handle,$_data);
    }

?>

采用

$length = strlen($_POST['data']);

使用$_FILES['filename']['size']获取上传的文件大小

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM