将图像保存在PHP的字节数组中


saving image in byte array in php

如何将图像文件保存到字节数组中。 我将图像文件作为 base64 发布到服务器。 和 Tehn 转换为 JPG。 但我不知道如何从 JPG 转换为字节数组

$base=$_POST["image"];
$binary=base64_decode($base);
$file = fopen("image.jpg", "w");
fwrite($file, $binary);
fclose($file);

您需要以二进制模式打开文件...

$file = fopen("image.jpg", "wb");

尝试imagecreatefromstring()函数:http://us.php.net/manual/en/function.imagecreatefromstring.php

(该页面上的示例与您的代码非常相似)