日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > php教程 > PHP 抓取遠程圖片并另存為的實現方法

PHP 抓取遠程圖片并另存為的實現方法

來源:程序員人生   發布時間:2014-02-24 00:06:53 閱讀次數:2436次

下面是源代碼,及其相關解釋

 <?php 
//URL是遠程的完整圖片地址,不能為空, $filename 是另存為的圖片名字 
//默認把圖片放在以此腳本相同的目錄里 
function GrabImage($url, $filename=""){ 
//$url 為空則返回 false; 
if($url == ""){return false;} 
$ext = strrchr($url, ".");//得到圖片的擴展名 
if($ext != ".gif" && $ext != ".jpg" && $ext != ".bmp"){echo "格式不支持!";return false;} 
if($filename == ""){$filename = time()."$ext";}//以時間戳另起名 
//開始捕捉 
ob_start(); 
readfile($url); 
$img = ob_get_contents(); 
ob_end_clean(); 
$size = strlen($img); 
$fp2 = fopen($filename , "a"); 
fwrite($fp2, $img); 
fclose($fp2); 
return $filename; 

//測試 
GrabImage("http://www.66xing.com/UploadFile/200609082320515027.bmp", "as.gif"); 
?>

相關描述:

ob_start : 打開輸出緩沖
This function will turn output buffering on. While output buffering is active no output is sent from the script (other than headers), instead the output is stored in an internal buffer. (輸出是在內部緩沖儲存)
//
readfile : 讀入一個文件并寫入到輸出緩沖
返回從文件中讀入的字節數。如果出錯返回 FALSE 并且除非是以 @readfile() 形式調用,否則會顯示錯誤信息。
//

ob_get_contents : Return the contents of the output buffer(返回輸出緩沖的內容)
This will return the contents of the output buffer without clearing it or FALSE, if output buffering isn't active. (如果輸出緩沖沒有活動(打開),則返回 FALSE)
//
ob_end_clean() : Clean (erase) the output buffer and turn off output buffering(清除輸出緩沖)
This function discards(丟棄) the contents of the topmost output buffer and turns off this output buffering.(丟棄并且關掉) If you want to further process the buffer's contents you have to call ob_get_contents() before ob_end_clean() as the buffer contents are discarded when ob_end_clean() is called. (如果要用緩沖內容,則在清理輸出緩沖之前要先調用 ob_get_contents())The function returns TRUE when it successfully discarded one buffer and FALSE otherwise. Reasons for failure are first that you called the function without an active buffer or that for some reason a buffer could not be deleted (possible for special buffer).

生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 国产综合视频在线观看 | 亚洲精品成人在线播放 | 欧美日韩成人一区 | 99精品欧美一区二区三区 | 久久久久久高清 | 在线无码 | 中文字幕五月 | 色精品 | 久久免费国产视频 | 91视视频在线观看入口直接观看 | 国产精品毛片一区二区在线看 | 亚洲一区二区在线 | 夜夜操av | 黄色欧美视频 | 欧美日韩视频 | 欧美日韩在线一区二区三区 | 国产精品视频999 | 国产中文视频 | 性欧美高清come| 久www | 欧美日韩精品一区二区三区四区 | 色婷婷色丁香 | 久久精品视频91 | 欧美一级欧美一级在线播放 | 中文字幕国产日韩 | 国产在线播放网址 | 日韩久久精品 | 国产视频a| 日本aⅴ毛片成人实战推荐 黄色成人在线观看 | 黄色欧美精品 | 影视在线观看 | 小草av| 嫩草影视大全 | 日韩裸女| 一区二区三区免费 | 国产精品久久二区 | 黄色毛片三级 | 国产精品日韩欧美一区二区三区 | 日韩爆操 | 国产一区二区三区久久悠悠色av | 成人在线日韩 |