php图片采集后按原路径保存图片,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <?php
$domain = 'http://www.jbxue.com' ;
$url = '/newskin/images/v4/logo.jpg' ;
$pats = pathinfo ( $url );
$dir = '.' . $pats [ 'dirname' ]. '/' ;
if (! is_dir ( $dir ))
{
@mkdirs( $dir , 0777);
@fclose( fopen ( $dir . '/index.htm' , 'w' ));
}
$img = file_get_contents ( $domain . $url );
file_put_contents ( '.' . $url , $img );
echo '<img src="' . $url . '" alt="php图片采集后按原路径保存图片,_PHP教程" >' ;
function mkdirs( $pathname , $mode = 0755){
is_dir (dirname( $pathname )) || mkdirs(dirname( $pathname ), $mode );
return is_dir ( $pathname ) || @ mkdir ( $pathname , $mode );
}
?>
|
로그인 후 복사
http://www.bkjia.com/PHPjc/1092698.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1092698.htmlTechArticlephp图片采集后按原路径保存图片, ?php$domain ='http://www.jbxue.com';$url = '/newskin/images/v4/logo.jpg';$pats = pathinfo($url);$dir = '.'.$pats['dirname'].'/';if(!is...