【问题标题】:POST data from C# to PHPPOST 数据从 C# 到 PHP
【发布时间】:2024-01-03 21:19:01
【问题描述】:

我通过 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/urldecode。

【问题讨论】:

    标签: c# php post base64 content-type


    【解决方案1】:

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

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

    【讨论】: