Reputation: 70997
I am trying to create a back-end for my mobile application. I am sending an image's contents as a byte array in the HTTP request's body (output stream) I want to read this stream of bytes in the PHP script and get back an image.
Can someone please tell me how I can do that?
Thanks.
Upvotes: 2
Views: 9814
Reputation: 300845
You can obtain the request body by reading from php://input
$body = file_get_contents('php://input');
What you do with that data is up to you. You could write the data to a file with file_put_contents. As you mentioned it is image data, you might also be able to drop the data into an ImageMagick object with Imagick::readImageBlob. Another alternative is to use GD and load the image with imagecreatefromstring.
Upvotes: 8