我正在构建聊天应用程序,需要发送和接收表情符号图像。我使用以下代码发布数据:

 let myUrl = NSURL(string: "http://test.php")
 let request = NSMutableURLRequest(URL:myUrl!)
 request.HTTPMethod = "POST"
 let postString = " shareImageMessage=\(message)"
 request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding)


我可以在调试区域中看到带有表情符号的消息,如下所示:

ios - 我的应用中仅显示一张表情符号图片-LMLPHP

但是只有以下图像显示在mysql数据库中:

ios - 我的应用中仅显示一张表情符号图片-LMLPHP

以及以下来自php脚本的代码:

$shareImageMessage = $_POST["shareImageMessage"];


我不明白为什么只有一种图像传输。

最佳答案

要在同一URL中发送多个表情符号,只需将要发送到服务器的字符串转换为base64,然后在数据库的另一端将其解码。要将字符串编码和解码为base64,可以选中此Convert between UIImage and Base64 string。 :)

10-06 13:25
查看更多