Answer the question
In order to leave comments, you need to log in
How to send files via CEvent::Send only sends 1 file?
Good, tell me the error. The form should send files to the mail, but for some reason only 1 file comes. The data goes through ajax.
<form id="mailForm" enctype="multipart/form-data" accept-charset="UTF-8">
<input id="email" class="email form-control" placeholder="<?=GetMessage('FORM3');?>" type="email"><br>
<input id="name" class="name form-control" placeholder="<?=GetMessage('FORM4');?>" type="text"><br>
<input id="phone_1" class="phone form-control" placeholder="+7 (___) ___ __ __" type="phone"><br>
<input type="hidden" value="<?echo SITE_ID;?>" id="csite" name="csite">
<input type="hidden" value="<?echo SITE_SERVER_NAME;?><?echo $APPLICATION->GetCurPage();?>" id="link" name="link">
<textarea style="display: block; width: 100%;" id="message" name="message form-control" placeholder="<?=GetMessage('FORM5');?>" rows="8" cols="80"></textarea><br>
<input id="file" name="file" type="file" multiple="multiple" /><br> <!--name="file[]"-->
<button type="button" id="sendMail" name="button" style="cursor: pointer;" class="btn btn-outline-success btn-success"><?=GetMessage('FORM6');?></button>
</form>
//собираем файлы из загрузки в массив .
$files=array();
foreach ($_FILES as $file){
if (!empty($file['tmp_name'])) {
$files[]=CFile::SaveFile($file,'form');
}
}
$mess = CEvent::Send("FORMA", $SITE, array(
"EMAIL" => $email,
"NAME" => $name,
"PHONE" => $phone_1,
"LINK" => $link,
"DATA" => $data,
"MESSAGE" => $message
), 'Y','',$files);
echo $mess;
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