Home >Backend Development >PHP Tutorial >Example of saving the image according to the original path after phpphp image collection_PHP tutorial

Example of saving the image according to the original path after phpphp image collection_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 10:24:521313browse

Copy code The code is as follows:

$domain ='http://www.jb51 .net';
$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.'">';

function mkdirs($pathname, $mode = 0755){
is_dir(dirname($pathname)) || mkdirs(dirname($pathname), $mode);
return is_dir($pathname) | | @mkdir($pathname, $mode);
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/825295.htmlTechArticleCopy the code as follows: ?php $domain ='http://www.jb51.net'; $url = '/newskin/images/v4/logo.jpg'; $pats = pathinfo($url); $dir = '.'.$pats['dirname'].'/'; if(!is_dir($dir) ) { @...
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