POST 从 C# 到 PHP 的数据

POST data from C# to PHP

我通过 POST 从 C# 应用程序向 PHP 发送数据。对于内容类型,我使用 application/x-www-form-urlencoded。工作正常。

现在我想发送一个base64代码。我发现在 application/x-www-form-urlencoded 中它删除了像 + 这样的特殊符号。这将破坏 base64 代码。我已经阅读了有关 urlencoding 和 urldecoiding 的内容。但在我看来这似乎不是一个可以接受的方式。此外,urldecode 的 PHP 函数不会正确更改 sighn +。

是否有其他通过 POST 发送数据的好方法,也许使用其他内容类型? application/json 或 application/xml 或 text/plain 怎么样? 它在 PHP 中的样子如何?

最重要的是防止urlencoding/urldecoding。

application/x-www-form-urlencoded 的内容类型必须进行 urlencoded,它是专门为此设计的。

如果您对 base64 数据进行 urlencode,那么在 PHP 上它将被恢复而无需使用任何其他函数,只需像往常一样访问 post 变量。