The code is very simple no more nonsense, directly to serve:
<?php Echo httpcopy ("Http://www.baidu.com/img/baidu_sylogo1.gif");
function Httpcopy ($url, $file = "", $timeout =60) {$file = empty ($file)? PathInfo ($url, pathinfo_basename): $file;
$dir = PathInfo ($file, pathinfo_dirname);
!is_dir ($dir) && @mkdir ($dir, 0755,true);
$url = Str_replace ("", "%20", $url);
if (function_exists (' Curl_init ')) {$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, $url);
curl_setopt ($ch, Curlopt_timeout, $timeout);
curl_setopt ($ch, Curlopt_returntransfer, TRUE);
$temp = curl_exec ($ch);
if (@file_put_contents ($file, $temp) &&!curl_error ($ch)) {return $file;
else {return false; } else {$opts = Array ("http" =>array ("method" => "Get", "header" => "", "timeout" =&
gt; $timeout));
$context = Stream_context_create ($opts);
if (@copy ($url, $file, $context)) {//$http _response_header return $file;
else {return false;
}
}}?>
and a remote download file to the server.
<form method= "POST" >
<input name= "url" size= "a"/> <input "submit" Name=
"Submit" type=
</form>
< php
//Maximum execution time in seconds
set_time_limit (* *);
if (!isset ($_post[' submit ')) Die ();
Folder to save downloaded the files to. Must end with slash
$destination _folder = ' temp/';
$url = $_post[' url '];
$newfname = $destination _folder. BaseName ($url);
$file = fopen ($url, "RB");
if ($file) {
$NEWF = fopen ($newfname, "WB");
if ($NEWF)
while (!feof ($file)) {
fwrite ($NEWF, Fread ($file, 1024 * 8), 1024 * 8);
}
if ($file) {
fclose ($file);
}
if ($NEWF) {
fclose ($NEWF);
>
The above mentioned is the entire content of this article, I hope you can enjoy.