最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
php自动保存远程图片类
时间:2010-05-14 编辑:简简单单 来源:一聚教程网
*/
class getromatePic{
var $savaDir ='pic/';
var $filePath ='http://www.111com.net/banner/banner.gif';
var $fileName ='111com.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.111com.net转载必须注明出处,否则必究。
-
上一个: 如何在php创建数据库与数据表
-
下一个: php连接mysql数据库
相关文章
- PHP导出数据超时的优化建议解读 10-31
- PHP之mysql位运算解析 10-31
- Laravel实现登录跳转功能解析 10-31
- php双向队列解读 10-31
- Laravel异常上下文解决教程 10-24
- php数组查询元素位置方法介绍 10-24