php - PHP如何获取二进制的post数据

标签 php post binary

我想将一些二进制数据发布到 PHP。
我知道我可以使用 php://input 或 $HTTP_RAW_POST_DATA 来读取它。
但它只能发布一个二进制数据。
我想发布两个键值数据,其各自的值是二进制的。
我们如何在 PHP 中做到这一点?

最佳答案

您可以使用 base64_encode() 以 Base64 编码二进制数据和 base64_decode() .

Base64 encoding schemes are commonly used when there is a need to encode binary data that needs to be stored and transferred over media that are designed to deal with textual data.

例如,您可以发布:

key1=eW91cmJpbmFyeWRhdGE=&key2=YmluYXJ5YWdhaW4=

在你的 PHP 中:

$myBinaryData1 = base64_decode($_POST['key1']);
$myBinaryData2 = base64_decode($_POST['key2']);

关于php - PHP如何获取二进制的post数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10596356/

相关文章:

php - Mandrill 提供无效的应用程序 key 错误

php - 使用 PHP mysql_connect 函数时绑定(bind)到特定的 ip 地址

php - 在sql查询中自动增加一个varchar

http - Solr 中多个过滤器查询与一个过滤器查询的性能差异

node.js - 使用 CORS 和 OpenShift 上的 Node 应用程序通过 POST 清空请求正文

javascript - 俄语字符错误地转换为二进制(JavaScript)

php - 将类添加到 Wordpress 图像 <a> anchor 元素

java - ArrayList 到 DavidWebb Android

php - mysql 在 utf8_general_ci 中区分大小写

iphone - iPad Info.plist 未转换为二进制文件