/** * Download remote picture to local * * @param $url string remote file Address * @param $filename string file name after save (the file name is randomly generated when empty, otherwise the original file name) * @param $fileType The file type allowed by array * @param the path saved by the $dirName string file (the remainder of the path is automatically genera
//
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 an
//
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 empty, the local file name will be based on the time an
Link Address: http://blog.sina.com.cn/s/blog_407a68fc0100nrb6.htmlImport java.io.IOException;Import Java.awt.image.BufferedImage;Import Java.net.URL;Import Java.io.BufferedInputStream;Import Java.io.OutputStream;Import Java.io.FileOutputStream;Import Java.io.File;Import Javax.imageio.ImageIO;public class Img2 {Read the remote URL picture to get a wide heightPublic int[] Returnimgwh (String imgurl) {Boolean
php gets header information through the Fsockopen method, and if the request is a picture, the content-length here represents the size of the picture If you want to get the size of a remote picture, it's a common practice to get the contents of the remote
1. Get the remote picture/**$Path to save the address of the picture$url the remote picture address to get**/function getimg ($path, $url) {$aext=Explode‘.‘,$url);$ext= End ($aext);$name = $path.' /'. Time () . '. ' . $ext;$source=file_get_contents ($url);File_put_contents (
);
}
}
.... At this time $message already the picture has been replaced with its own server local address, and the picture is also saved to its own server.
Copy Code code as follows:
One of the following functions and classes is found on the network.
Get the domain name from the URL
function Get_domain ($url) {
$pattern = "/[\w-]+\." (COM|NET|ORG|GOV|CC|BIZ|INFO|CN) (\. (CN|HK))
The method by which PHP collects remote images with image addresses in the content and saves them
In this paper, we describe the remote picture with image address in PHP collection and save the method. Share to everyone for your reference. The implementation method is as follows:
Copy CodeThe code is as follows: function my_file_get_contents ($url, $timeout =30)
To share a function code that uses PHP to get remote pictures and save remote pictures to local, hopefully this tip will come in handy.
/** function: PHP Perfect implementation download remote picture saved to local * parameters: File URL, save file directory, save file name, use the download method * When the save fi
In order to allow local pictures, remote pictures, too small pictures are adapted to this plug-in, there are many details to deal with.
First, define the structure:
Then consider the picture preload:
$.imgPreloader=function(url,eventLists){
var img=new Image();
var $img=$(img);
img.src=url;
$.each(eventLists,function(type,fn){
$img.bind
Save remote Picture code do not know how to modify the save path wait for the master advice
//
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
Example, a PHP get remote picture class. Code:
if (! defined (' BasePath ')) exit (' No direct script access allowed ');
/*
* Remote access to picture class
*
* Requires the curl extension to be turned on
* Simulates the PHP upload principle, creates a cache directory,
Because the company's website before the user picture is stored on their own server, and then feel that management is not convenient, the new added user avatar has been uploaded to seven of cattle, in order to facilitate unified management, the leader said the local server's avatar all migrated to seven cattle.
1. Sort out the ideas
First of all to determine whether the user's avatar in seven cattle, if not present, if there is a local crawl to seven
Usage echo remote_filesize ($url, $user = ", $PW =");
$url = "http://www.aa.com/librarys/images/random/rand_11.jpg";//Picture address
Echo remote_filesize ($url, $user = ", $PW =");
function Remote_filesize ($uri, $user = ", $PW =")
{
Start output buffering
Ob_start ();
Initialize curl with given URI
$ch = Curl_init ($uri); Make sure we get the header
curl_setopt ($ch, Curlopt_header, 1); Make it a HTTP HEA
PHP Save the remote server on the picture, in fact, this is also called collection, the remote server to save the picture to their own server, and the collection of articles similar to the collection of pictures added a header (' content-type:image/png '); Declare the type of content of the article, And the article is
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.