//
Function: Get the remote picture and save it locally
//
//
Make sure you have permission to write files to the local server
//
//
Variable Description:
$url is the full URL address of the remote picture and cannot be empty.
$filename is an optional variable: If blank, the local file name will be 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);
$FP 2= @fopen ($filename, "a");
Fwrite ($fp 2, $img);
Fclose ($fp 2);
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.html www.bkjia.com true http://www.bkjia.com/PHPjc/508426.html techarticle ? PHP///Function: Get the remote picture and save it to local//////To make sure you have permission to write the file to the local server//////or $url is the full remote picture ...