Answer the question
In order to leave comments, you need to log in
How to add a file from a form to the infoblock property?
There is a form
echo "<form id='formPromo' enctype='multipart/form-data'>
Название:<input name='name' value='$name'/> <br>
Дата:<input name='date' type ='date'/><br>
Описание:<textarea name='discription'></textarea><br>
Ссылка:<input name='addres' value='$link'/><br><br>
Картинка:
<br><br>
<input name='picture' type ='file' multiple/><br>
<input name='id' value='$id' type='hidden'/>
<br><br>
<input value='Добавить' type='submit'/>
<input type='hidden' name='clinikID' value='$idClinick'>
</form>";
<?php
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
$APPLICATION->SetTitle("Title");
if(isset($_POST['name'])&&$_POST['name']!="")
{
$name = htmlentities($_POST['name']);
$date = htmlentities($_POST['date']);
$discription = htmlentities($_POST['discription']);
$addres = htmlentities($_POST['addres']);
$id = htmlentities($_POST['id']);
$clinikID = htmlentities($_POST['clinikID']);
$picture = $_FILES['picture'];
if (CModule::IncludeModule('iblock')){
if($id){
$arProp["NAME"] = $name;
$arProp["LINK"] = $addres;
$arProp["CLINIK"] = $clinikID;
$arFields = array(
'NAME' => $name."-".$date,
'MODIFIED_BY' => $USER->GetID(),
'IBLOCK_ID' => 13,
'ACTIVE' => 'Y',
'PROPERTY_VALUES' => $arProp,
"IBLOCK_SECTION" => false
);
$el = new CIBlockElement;
$intOfferID = $el->Update($id,$arFields);
}else{
$el = new CIBlockElement;
$arProp["NAME"] = $name;
$arProp["LINK"] = $addres;
$arProp["CLINIK"] = $clinikID;
$arFields = array(
'NAME' => $name."-".$date,
'MODIFIED_BY' => $USER->GetID(),
'IBLOCK_ID' => 13,
'ACTIVE' => 'Y',
'PROPERTY_VALUES' => $arProp
);
$intOfferID = $el->Add($arFields);
}
}
}
?>
Answer the question
In order to leave comments, you need to log in
Something after declaring a variable, $picture = $_FILES['picture'];
I do not see its further use. What exactly is missing from the picture?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question