【发布时间】:2014-02-14 22:53:34
【问题描述】:
我想知道是否有人可以帮我解决这个问题,我正在从我的 windows phone c# 发送图像到 php,我想保存图像。
数据连接正常,我可以收到 POST 值 有关服务器接收的信息,请参阅:http://posttestserver.com/data/2014/01/23/19.41.40516059397。
我现在想将这个 base64 编码的 RGBA 字符串保存为 png 或 jpg(我更喜欢 png,但我不需要 alpha 值)。
这是我在服务器端的代码
//getimagecontents
$data = base64_decode(file_get_contents("php://input"));
//create an image from string
$im = imagecreatefromstring($data);
if ($im !== false) {
//add an header for the image
header('Content-Type: image/png');
//save the image
imagepng($im, 'upload/test.png');
imagedestroy($im);
echo "it worked!";
}
希望有人能帮我解决这个问题,因为它让我彻夜难眠:(
提前致谢:)
【问题讨论】: