Answer the question
In order to leave comments, you need to log in
Bitrix. How to upload a file and get its id?
Hello! I ask for help in the implementation. In general, there is a form for uploading images, which I write myself, without using built-in components. The form must load a picture into the "file" type property. How to implement it in Bitrix? The problem is in loading and getting the id, writing to the property occurs if you manually write the id of an already loaded image.
< form name="iblock_add" id="iblock_add" method="POST" action="<?=POST_FORM_ACTION_URI?>" enctype="multipart/form-data" >
$value = $arResult["PROPERTIES"][$propertyName ]['ID']['VALUE'];
< input type="hidden" name="PROPERTY[<?=$arResult['PROPERTIES'][$propertyName]['ID']?>][0]" value="<?=$value?>">
< input type="submit" class="submitbutton" name="<?if(!$arResult["UPDATE"]):?>submit_iblock_add<?else:?>submit_iblock_update<?endif?>" value="SAVE" />
</form>
Answer the question
In order to leave comments, you need to log in
The article is fresh - I just read it - https://dev.1c-bitrix.ru/community/webdev/user/640...
I solved your
problem like this, I really don’t understand the meaning
<form action="" method="POST">
<?foreach ($_POST["NEW_FILE_UPLOAD"] as $key => $item):?>
<?$img = htmlspecialchars($item);?>
<img src="<?=CFIle::GetPath($img)?>" width="150px">
<?endforeach?>
<?$APPLICATION->IncludeComponent("bitrix:main.file.input", "drag_n_drop",
array(
"INPUT_NAME"=>"NEW_FILE_UPLOAD",
"MULTIPLE"=>"Y",
"MODULE_ID"=>"main",
"MAX_FILE_SIZE"=>"",
"ALLOW_UPLOAD"=>"A",
"ALLOW_UPLOAD_EXT"=>"",
"INPUT_CAPTION" => "Добавить фото",
"INPUT_VALUE" => $_POST['NEW_FILE_UPLOAD']
),
false
);?>
<input class="pic" type="text" value="" id="newF">
<input type="submit" value="Отправить">
</form>
var inp = BX("newF");
BX.adjust(inp, {props: {value: result.element_id}});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question