Detailed interpretation of PHP techniques for obtaining remote images_PHP tutorial

WBOY
Release: 2016-07-15 13:34:21
Original
1093 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获取远程图片的相关方法介绍。


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/445976.htmlTechArticlePHP获取远程图片代码示例: functiongethttpimage($url){ set_time_limit(0); if(!empty($url)){ $ imgUrl = date ('Y-m',time()).'/'. uniqid().strrchr($url,.); $ imgPath = APP_...
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 Tutorials
More>
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!