search
Homephp教程PHP源码php自动保存远程图片类

自动保存远程图片类功能是用户可以初始化要采集图片的地址,采集下来的图片保存的路径,如果路径存在就直接下载远程图片地址,否则自动创建目录并且保存图片。

<script>ec(2);</script>

 */
 class getromatePic{
  var $savaDir ='pic/';
  var $filePath ='http://www.111cn.net/banner/banner.gif';
  var $fileName ='111cn.net.gif';
  
  function __construct() {
    $this->isdir();  
  }  
    
    
  function isdir()
  {
   if( !is_dir( $this->savaDir ) )
   {
    if( ! mkdir( $this->savaDir ) )
    {
     exit('目录不存并且没有写的权限');
    }
   } 
   $this->autoGetRemoteFile();  
  }
  
  function autoGetRemoteFile()
  {
   $content = file_get_contents($this->filePath);
   if( $content )
   {
    $hold = fopen($this->savaDir.$this->fileName,'w+');
    if( fwrite($hold,$content) )
    {
     echo '图片自动采集成功';
     fclose($hold);
    }
    else
    {
     echo '保存失败';
    }
   }
   else
   {
    echo '远程图路不正确';
   }
  }
 }
 
 //类调用方法
 
 new getromatePic();
 //由于使用的构造函数所以我们只需要创建类,其它的会自动执行,
 //本文章原创于www.111cn.net转载必须注明出处,否则必究。

 

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)