【www.gdgbn.com--远程及网络应用】
*/
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转载必须注明出处,否则必究。