The following code is a code example of a PHP fetch image:
- < ? PHP
- Variable Description:
- $url is the full URL address of the remote picture and cannot be empty.
- $filename is an optional variable: if empty,
Local file names are automatically generated based on time and date.
- 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, "a");
- Fwrite ($fp 2, $img);
- Fclose ($fp 2);
- return $filename;
- }
- $ img = Grabimage ("Picture path", "");
- if ($img): Echo ' < Pre >
< img src="'. $img. '" > pre>';
- Else:echo "false";
- endif
- ?>
I hope you can use this article to introduce the method of PHP grab pictures, skillfully apply this method.
http://www.bkjia.com/PHPjc/446171.html www.bkjia.com true http://www.bkjia.com/PHPjc/446171.html techarticle The following code is a code example of PHP fetching a picture:? PHP//Variable Description://$url is the full URL address of the remote picture and cannot be empty. $filename is an optional variable: if it is empty, the local text ...