PHP retrieves remote images .? PhpFunction: get the remote image and save it locally. Make sure you have the permission variable to write the file to the local server. description: $ url is complete for the remote image. //
// Function: obtain the remote image and save it to the local device.
//
//
// Make sure you have the permission to write files to the local server
//
//
// Variable description:
// $ Url is the complete URL of the remote image. it cannot be blank.
// $ Filename is an optional variable. if it is null, the local file name is based on the time and date.
// Automatically generated.
Function GrabImage ($ url, $ filename = ""){
If ($ url = ""): return false; endif;
If ($ filename = ""){
$ Ext = strrchr ($ url ,".");
If ($ ext! = ". Gif" & $ ext! = ". Jpg"): return false; endif;
$ Filename = date ("dMYHis"). $ ext;
}
Ob_start ();
Readfile ($ url );
$ Img = ob_get_contents ();
Ob_end_clean ();
$ Size = strlen ($ img );
$ Fp2 = @ fopen ($ filename, "");
Fwrite ($ fp2, $ img );
Fclose ($ fp2 );
Return $ filename;
}
$ Img = GrabImage ("http://www.BkJia.com/images/_1978837_detector_ap100.jpg ","");
If ($ img): echo'
';
Else: echo "false ";
Endif;
?>
Http://www.bkjia.com/PHPjc/508426.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/508426.htmlTechArticle? Php /// Function: obtain the remote image and save it to the local device. //// make sure you have the permission to write the file to the local server. //// variable description: // $ url is the complete remote image...