Answer the question
In order to leave comments, you need to log in
How to upload a picture to a profile via update??
Good afternoon, I ran into a problem when updating a user photo.
Actually the previous photo is deleted, but the new one does not appear. I rummaged through the Internet and did not find anything ((
There are no errors, at the end the script returns true ..
$arFile2 = CFile::MakeFileArray($_FILES['file']['tmp_name'][0]);
$userId = $USER->GetId();
$rsUser = CUser::GetByID($userId);
$arUser = $rsUser->Fetch();
$arFile2['del'] = "Y";
$arFile2['old_file'] = $arUser["PERSONAL_PHOTO"];
$arFile2["MODULE_ID"] = "main";
$fid = CFile::SaveFile($arFile2, "main");
$fields = Array( "PERSONAL_PHOTO" => $fid );
$user = new CUser;
$res = $user->Update($userId, $fields);
$strError .= $user->LAST_ERROR;
Answer the question
In order to leave comments, you need to log in
$arr_file = array(
"name" =>$_FILES['file']['name'],
"size" =>$_FILES['file']['size'],
"tmp_name" =>$_FILES['file']['tmp_name'],
"type" => "",
"old_file" => "",
"del" => "Y",
"MODULE_ID" => ""
);
$fid = CFile::SaveFile($arr_file, "patch");
$fields = Array( "PERSONAL_PHOTO" => $arFile2 );
Show the contents of the $arFile2 array when the file is loaded
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question