if(strlen($imgUrl)>0)
{
if(copy($imgUrl, $arUser['user_fields']['ID'].".jpg"))
{
$arFile = CFile::MakeFileArray($_SERVER["DOCUMENT_ROOT"]."/login/".$arUser['user_fields']['ID'].".jpg");
$arFile["MODULE_ID"] = "main";
$fid = CFile::SaveFile($arFile, "main");
if (intval($fid)>0)
{
$arPhoto = CFile::MakeFileArray($fid);
$user = new CUser;
$fields = Array(
"PERSONAL_PHOTO" => $arPhoto,
);
$user->Update($arUser['user_fields']['ID'], $fields);
CFile::Delete($fid);
unlink($_SERVER["DOCUMENT_ROOT"]."/login/".$arUser['user_fields']['ID'].".jpg");
}
}
} |