Home > php教程 > php手册 > 详细解读PHP获取远程图片技巧

详细解读PHP获取远程图片技巧

WBOY
Release: 2016-06-13 11:11:31
Original
992 people have browsed it

PHP获取远程图片代码示例:

  1. function gethttpimage($url){  
  2. set_time_limit(0);  
  3. if(!empty($url)){  
  4. $imgUrl=date('Y-m',time()).'/'.
    uniqid().strrchr($url,".");  
  5. $imgPath=APP_PATH.'/Public
    /uploads/';   
  6. $filename=$imgPath.$imgUrl;   
  7. if(!is_dir($imgPath)) @mkdir
    ($imgPath,0777);  
  8. $get_file=@file_get_
    contents($url);   
  9. if($get_file){  
  10. $fp=@fopen($filename,"w");  
  11. @fwrite($fp,$get_file);  
  12. @fclose($fp);  
  13. }   
  14. return $imgUrl;  
  15. }else{  
  16. return false;  
  17. }   
  18. }  

以上这段代码就是PHP获取远程图片的相关方法介绍。


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