PHP receives binary stream save picture
Now do PHP to receive pictures from the ipad, save and display in the background, how to receive AH and save as a picture ah, passed over is the twos into the data circulated, seeking expert guidance Thank you
------Solution--------------------
Just write the picture. File_put_contents ("File.png", $data);
------Solution--------------------
Take picture binary
Put a picture test.jpg under the C drive
function Imgdata ()
{
$img _file = ' c:/test.jpg ';
$fp = fopen ($img _file, ' RB ');
$content = Fread ($fp, FileSize ($img _file)); Binary data
Fclose ($FP);
return $content;
}
/**
* Save the binary as a picture
* $dxycontent Picture binary data
* $filepath Picture Path
* $filename Picture Name
*/
function Imgsave ($dxycontent, $filepath, $filename)
{
Get the binary raw data from the post.
$file = fopen ($filepath. $filename, "w"); Open file ready to write
Fwrite ($file, $dxycontent); Write
Fclose ($file); Shut down
}
Imgsave (Imgdata (), "d:/", "test.jpg");
------Solution--------------------
$stream = file_get_contents (' php://input ');
$GD = imagecreatefromstring ($stream);
Imagepng ($GD, '/xxx.png ');