phpphp image collection after the original path to save the image example

  • 2021-01-14 05:43:47
  • OfStack


<?php
$domain ='https://www.ofstack.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.'">';
function mkdirs($pathname, $mode = 0755){
 is_dir(dirname($pathname)) || mkdirs(dirname($pathname), $mode);
 return is_dir($pathname) || @mkdir($pathname, $mode);
}
?>


Related articles: