function GrabImage($url,$filename="") {
if($url=="") return false;
if($filename=="") {
$ext=strrchr($url,".");
if($ext!=".gif" && $ext!=".jpg" && $ext!=".png") return false;
$filename=date("YmdHis").$ext;
}
ob_start();
readfile($url);
$img = ob_get_contents();
ob_end_clean();
$size = strlen($img);
[email protected]($filename, "a");
fwrite($fp2,$img);
fclose($fp2);
return $filename;
}
foreach($arr as $_arr){
$sql_yanzheng = "SELECT sku, VALUE AS img_url
FROM catalog_product_entity_media_gallery
INNER JOIN catalog_product_flat_1 ON catalog_product_flat_1.entity_id = catalog_product_entity_media_gallery.entity_id
WHERE sku = ‘".$_arr."‘";
$rows = mysql_query($sql_yanzheng);
$i=0;
while($row = mysql_fetch_array($rows)){
echo "http://www.lucluc.com/media/catalog/product".$row[‘img_url‘];echo ‘<br>‘;
echo $row[‘sku‘]."/".$i.".jpg";
$img=GrabImage("http://www.lucluc.com/media/catalog/product".$row[‘img_url‘],$row[‘sku‘]."/".$i.".jpg");
$i++;
}
}