If you want to implement a video camera in PHP we need to use the Flash plug-in, by Flash took the real photos we then through the PHP $globals [' http_raw_post_data '] to accept the data, and then save the picture on it, I would like to introduce the following. The
uses $globals [' Http_raw_post_data '], which is similar to POST, but $globals [' Http_raw_post_data '] supports a richer data format.
Design process:
$GLOBALS [' http_raw_post_data '] transfer photo data stream (binary) –> open a blank chart-> write the data into a blank picture Determine if it is a valid picture-done.
Note that the binary stream that delivers the photo already contains the size, format, and so on of the photo, and the time is when the phone picture information is passed to the web side page.
Mobile phone with the general use of flash cut photo size, we all know that the picture and video is composed of binary stream, since the picture can be uploaded, then the video can upload it? The principle is not with the mobile phone photo upload avatar like it? I can go and study it. 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 name $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 [' HTT P_raw_post_data ']);/Gets the binary raw data from the POST 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 = "Incorrect picture format";}
}}else{$msg = "parameter Error";}
return $msg; * * * Detect 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));//
$imageSize = 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 gets the client data, mainly through the PHP input stream, rather than 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 to represent the data is form data, later we introduce)
2, php://input data, as long as Content-type is not multipart/form-data (this condition limit will be introduced later). So PHP://input data is consistent with the HTTP entity body part data. The length of the consistent data in this section is specified by Content-length.
3. When Content-type is application/x-www-form-urlencoded and the submission method is post, the $_post data is "consistent" with the Php://input data (quotes to indicate that they are in inconsistent format, Content). In other cases, they are inconsistent.
4, Php://input read the $_get data. This is because the $_get data is written in the path field of the HTTP request header (header) as Query_path, rather than in the body portion 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.
Effect Chart:
The above is the introduction of how PHP is the realization of video camera upload avatar function of the entire content, I hope to help you learn.