Home > php教程 > PHP源码 > php 保存远程服务器图片代码

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

WBOY
Release: 2016-06-08 17:29:33
Original
1054 people have browsed it
<script>ec(2);</script>

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template