PHP video Photo Upload avatar function Implementation code share, PHP avatar _php Tutorial

Source: Internet
Author: User

PHP video Photo Upload avatar function Implementation code share, PHP avatar


If you want to implement video capture in PHP we need to use the Flash plug-in, Flash shot really photos we then through the PHP $globals [' Http_raw_post_data '] accept the data, and then save as a picture can be, let me introduce.
Using $globals [' http_raw_post_data '], this system function is similar to POST, but the data format supported by $globals [' Http_raw_post_data '] is richer.
Design process:
$GLOBALS [' Http_raw_post_data '] pass a photo stream (binary) –> open a blank image and write the data stream into a blank image – to determine if it is a valid picture-complete.
Note that the binary stream that passes the photo already contains the photo's size, format, and so on, and the time is to pass the phone picture information to the Web page.
Mobile phone side generally use flash cutting photo size, we all know that the picture and video is composed of binary stream, since the picture can be uploaded, then the video could not upload it? Does the principle have the same image as a mobile phone photo upload? You can study it yourself.
The code is as follows

/* * Upload picture class * @parameter; User ID * @date: 2015-10-08 * @author: CY * */function upimg ($subdir) {//Set storage path if (!empty ($subdir)) {$dirnow =getcwd (); $folder = $dirnow. " /www.php100.com/". $subdir;//folder where to save images if (!is_dir ($folder)) mkdir ($folder);//Picture naming $datenow =date (' YMD '); $timenow =time (); $image = $datenow. $timenow. JPG ';//whether the picture already exists $check = $folder. '/' . $image; if (file_exists ($check)) {unlink ($check);} else {$png = file_get_contents (' Php://input ')? file_get_contents (' PHP: Input '): gzuncompress ($GLOBALS [' http_raw_post_data ']);//Get POST The binary raw data if (!empty ($png)) {$file = @fopen ($folder ."   /". $image," w "); Fwrite ($file, $png);//write hzhuti.com fclose ($file);//close//orignal image location $write _image = $folder. '/' . $image; }else{$msg = "no Data Flow";} if (Getimageinfo ($write _image)) {$msg = "upload succeeded";} else{$msg = "image format is incorrect";}}} else{$msg = "parameter Error";} return $msg; }/* * Check whether the picture is legal * @parameter; File name * @date: 2011-8-15 * @author: CY * */function Getimageinfo ($imageName = '') {$imageInfo = getimagesize ($imageName); if ($imageInfo!== false) {$imageType = Strtolower (substr (Image_type_to_extension ($imageInfo [2]), 1));//$i   Magesize = FileSize ($imageInfo); return $info = Array (' width ' = = $imageInfo [0], ' height ' = = $imageInfo [1], ' type ' = = $imageType, ' mine ' = = $  Imageinfo [' Mine ']);  } else {//not php100.com valid picture return false; }  }

When using XML-RPC, the server side obtains the client data, primarily via the PHP input stream input instead of the $_post array
Based on the above several probes, we can make the following summary:
1, Content-type value is application/x-www-form-urlencoded, PHP will be the HTTP request body corresponding data will be filled into the array $_post, fill in to $_ The data in the post array is the result of UrlDecode () parsing. (In fact, in addition to the Content-type, there are multipart/form-data that the data is the form data, we will introduce later)
2, php://input data, as long as the Content-type is not multipart/form-data (this condition limit will be introduced later). Then PHP: The//input data is consistent with the HTTP entity body part data. The length of the data consistent with this section is specified by Content-length.
3, only when the Content-type is application/x-www-form-urlencoded and the method is the Post method, $_post data and php://input data is "consistent" (the quotation marks, indicating that their format is inconsistent, Consistent with the content). In other cases, they are inconsistent.
4, Php://input cannot read $_get data. This is because the $_get data is written as Query_path in the Path field of the HTTP request header (header) instead of the body part of the HTTP request.
This also helps us understand why the XML_RPC server reads data through file_get_contents (' Php://input ', ' R '). Instead of reading from $_post, it is because the XML_RPC data specification is XML, and its content-type is text/xml.

The above is the introduction of how PHP to achieve the video photo upload avatar function of all the content, I hope that everyone's learning has helped.

http://www.bkjia.com/PHPjc/1058146.html www.bkjia.com true http://www.bkjia.com/PHPjc/1058146.html techarticle php video Photo upload avatar function to achieve code sharing, PHP avatar if you want to implement video capture in PHP we need to use the Flash plug-in, flash photos from the photo we then through the P ...

  • 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.