Answer the question
In order to leave comments, you need to log in
How to add a file to a custom field "file"?
Hello!
I'm making a file uploader. I save downloads in HL.
To save a file, I use the CFile::SaveFile method . The file is downloaded and the ID of that file is returned to me.
if (is_uploaded_file($_FILES["file"]["tmp_name"])) {
$arFileArray = array(
"name" => $_FILES["file"]["name"],
"size" => $_FILES["file"]["size"],
"tmp_name" => $_FILES["file"]["tmp_name"],
"type" => $_FILES["file"]["type"],
"MODULE_ID" => "highloadblock"
);
$FileID = CFile::SaveFile($arFileArray, "highloadblock");
}
$hlblock_id = 1;
$hlblock = HL\HighloadBlockTable::getById($hlblock_id)->Fetch();
$entity = HL\HighloadBlockTable::compileEntity($hlblock);
$entity_data_class = $entity->getDataClass();
$result = $entity_data_class::add(
"UF_UPLOAD_FILE" => $FileID
);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question