How php converts a binary file to an image

Source: Internet
Author: User
How php converts a binary file to an image
This article describes how to use php to receive binary code and convert it to an image. For more information, see.

Php develops a program for generating images by cropping images online in Flash, and sends the binary data of the Flash POST image to php. The php generates images for storage.

Receiving data with $ _ POST is not acceptable, and PHP only recognizes the application/x-www.form-urlencoded standard data type by default. Therefore, text/xml, soap, application/octet-stream and other types cannot be parsed. if you use the $ _ POST array to receive them, it will fail! Therefore, the prototype is retained and sent to $ GLOBALS ['http _ RAW_POST_DATA '] for receiving.

In addition, php: // input can also implement this function.

Php: // input allows reading original POST data. Compared with $ HTTP_RAW_POST_DATA, it puts less pressure on the memory and does not require any special php. ini settings. Php: // input and $ HTTP_RAW_POST_DATA cannot be used for enctype = "multipart/form-data ".

Use JPGEncoder in Flash to convert BitMapData to binary, and then post it to php code.

1. php page code

     

2. applications in thinkphp;

     

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.