PHP - get image from byte array

前端 未结 1 1285
忘掉有多难
忘掉有多难 2021-01-03 14:31

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

相关标签:
1条回答
  • 2021-01-03 15:05

    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.

    0 讨论(0)
提交回复
热议问题