PHP multiple binary stream picture/file what to do

Source: Internet
Author: User
PHP multiple binary stream Pictures/files how to handle
1. Functional requirements is this, the mobile phone interface needs to complete a upload multiple images of the interface, and webserver need to accept the binary stream, generate pictures, save local, and save the address of the database;
2. There is now a problem: How to get multiple binary streams and convert multiple binary flows into corresponding pictures to save to local
3. Here's how to receive a binary stream picture processing:
Binary Data Flow
$file _data = file_get_contents (' Php://input ')? file_get_contents (' Php://input '): gzuncompress ($GLOBALS [' http_raw_post_data ']);
The data stream is not empty, then the save operation
if (! empty ($file _data)) {
$save _name=md5 (Get_gmtime (). Mt_rand (10,99)). ". JPG ";
$path =create_dir ();
Create and write a data stream, and then save the file
if (@ $fp = fopen ($path [' File_path ']. $save _name, ' w+ ')} {
Fwrite ($fp, $file _data);
Fclose ($FP);
if (file_exists ($path [' File_path ']. $save _name)) {
Ajax_return (Array (' recode ' = ' 0000 ', ' msg ' = ' operation succeeded ', ' data ' = ') ');
} else {
Ajax_return (' recode ' = ' 9001 ', ' msg ' = ' + ' supports only image type uploads in jpg,png,jpeg,gif format, GIF animated images will not be animated after uploading, ' data ' = ' " ));
}
} else {
Ajax_return (Array (' recode ' = ' 0001 ', ' msg ' = ' operation failed ', ' data ' = '));
}
} else {
No data stream received
Ajax_return (Array (' recode ' = ' 0001 ', ' msg ' = "Please select the image to upload", "data ' ="));
}
Binary Stream binary stream Picture save multiple binary stream files saved

Share to:


------Solution--------------------
$_files uses him to read and get the picture data.
  • 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.