There are many ways to capture remote images. in this article, we will introduce how php is implemented. if you are interested, you can understand it.
The code is as follows:
Function grabImage ($ url, $ filename = ''){
If ($ url = ''){
Return false; // if $ url is null, false is returned;
}
$ Ext_name = strrchr ($ url, '.'); // Obtain the image extension.
If ($ ext_name! = '.Gif '& $ ext_name! = '.Jpg '& $ ext_name! = '.Bmp '& $ ext_name! = '.Png '){
Return false; // The format is not in the permitted range.
}
If ($ filename = ''){
$ Filename = time (). $ ext_name; // name it with a timestamp
}
// Start capture
Ob_start ();
Readfile ($ url );
$ Img_data = ob_get_contents ();
Ob_end_clean ();
$ Size = strlen ($ img_data );
$ Local_file = fopen ($ filename, 'A ');
Fwrite ($ local_file, $ img_data );
Fclose ($ local_file );
Return $ filename;
}