自动保存远程图片类功能是用户可以初始化要采集图片的地址,采集下来的图片保存的路径,如果路径存在就直接下载远程图片地址,否则自动创建目录并且保存图片。
*/
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转载必须注明出处,否则必究。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.