As SYP}{ER points out you have to get the filetype as well
<?
$user="joe";
if($HTTP_POST_FILES['infile']['tmp_name'])
{
$path=$new_home_for_image.$HTTP_POST_FILES['infile']['name'];
if(!copy($HTTP_POST_FILES['infile']['tmp_name'],$path))
{
echo "doh";
}else{
$type=array('','.gif','.jpg','.png','.swf');
$bits=getimagesize($path);
$newname=$user.$type[$bits[2]];
if(rename($path,str_replace($HTTP_POST_FILES['infile']['name'],$newname,$path)))
{
echo "whoot!";
}
}
}?>
or just rename when copying
<?
$user="joe";
if($HTTP_POST_FILES['infile']['tmp_name'])
{
$path=$new_home_for_image.$HTTP_POST_FILES['infile']['name'];
$type=array('','.gif','.jpg','.png','.swf');
$bits=getimagesize($path);
$newname=$user.$type[$bits[2]];
if(!copy($HTTP_POST_FILES['infile']['tmp_name'],str_replace($HTTP_POST_FILES['infile']['name'],$newname,$path)))
{
echo "doh";
}else{
echo "whoot!";
}
}?>