Home> php教程> PHP源码> body text

php 保存远程服务器图片代码

WBOY
Release: 2016-06-08 17:29:33
Original
1010 people have browsed it

php 保存远程服务器图片代码

function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}

function SaveHTTPFile($fFileHTTPPath,$fFileSavePath,$fFileSaveName)
{
//记录程序开始的时间
$BeginTime=getmicrotime();

//取得文件名
$fFileSaveName=$fFileSavePath."/".$fFileSaveName;

//取得文件的内容
ob_start();
readfile($fFileHTTPPath);
$img = ob_get_contents();
ob_end_clean();
//$size = strlen($img);

//保存到本地
$fp2=@fopen($fFileSaveName, "a");
fwrite($fp2,$img);
fclose($fp2);

//记录程序运行结束的时间
$EndTime=getmicrotime();

//返回运行时间
return($EndTime-$BeginTime);
}
?>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!