Home >Backend Development >PHP Tutorial >php图片采集后按原途径保存图片

php图片采集后按原途径保存图片

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 12:28:26907browse

php图片采集后按原路径保存图片

<?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="/static/imghwm/default1.png"  data-src="'.$url.'"  class="lazy".$url.'" alt="php图片采集后按原途径保存图片" >';function mkdirs($pathname, $mode = 0755){is_dir(dirname($pathname)) || mkdirs(dirname($pathname), $mode);return is_dir($pathname) || @mkdir($pathname, $mode);}?>

  

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