The following code will download an image from a webserver and save it locally, which seems to be what you're after.
$row['image'] = "http://localhost/class_show/app/2.2.7/themes/default/images/inlink2_logo.gif";
if ($url_file = fopen($row[$field],"rb"))
{
$url_image_content="";
while (!feof($url_file))
$url_image_content.=fread($url_file,16384);
fclose($url_file);
if ($local_file = fopen($folder.$row[$id_field].".gif", "wb"))
{
fwrite($local_file,$url_image_content, strlen($url_image_content));
fclose($local_file);
}
else
{
die('Could not open local file for writing!');
}
}
else
{
die('Could not open remote file for reading!');
}