PHP Save remote picture, the following code is my own writing, but there is a problem is placed on the server to save the picture success is not very high, I use is file_get_contents to obtain, finally found if the host has anti-theft of the study
Php saves remote images. Php saves the remote image. the following code is written by myself. However, the success of saving the image on the server is not very high. I used file_get_contents to retrieve the image, at last, php saved the remote
PHP download remote picture and save to local method summary,
1. functions to obtain remote file size and information
function GetFileSize ($url) {$url = Parse_url ($url), if ($fp = @fsockopen ($url [' Host '],empty ($url [' Port ']): $url [' Port '
PHP downloads the remote image and saves it to the local method summary ,. PHP downloads remote images and saves them to a local directory. functiongetFileSize ($ url) {$ urlparse_url ($ url ); if ($ fp @ fsockopen ($ url [h PHP downloads remote
Today, a simple collection program needs to download the content of the website of the other party, and then store the images in the content on the local server. Next I will introduce you to my specific operation methods, the file_get_contents
Here we use the regular expression of PHP to implement:
The code is as follows
Copy Code
$content = ' Here is the content of the article, insert here a picture test ';$content = Stripslashes ($content);$img _array =
In php, we often use some simple collection functions to automatically save images or resources from remote servers to the local servers, next I will introduce the remote image in detail and save it to a local machine.
Example 1
The Code
Function class for saving php remote images to a local device .? PhpFunction: get the remote image and save it locally. Make sure you have the permission to write the file to the local server. description: $ url is the complete U of the remote image.
Example 1
The code is as follows
Copy Code
/** Function: PHP a variety of ways to achieve the perfect download remote pictures saved to local* Parameters: File URL, save file name, use the download method* Use the
Php regular expression matches the remote image address in the article and downloads the image to the local device. Today, a simple collection program needs to download the content of the website of the other party, and then save the image in the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.