Answer the question
In order to leave comments, you need to log in
A letter from the feedback comes, but there is no attachment, what's wrong?
Hello.
Purpose: to add to the standard functionality of the feedback component the ability to send attachments (with a weight limit of no more than 10mb).
What I did: copied the Bitrix feedback component to another folder, started changing it. Here is a code snippet below, where I added saving the file first, and then sending it. But the attachment does not come, what's wrong? Tell me please.
if($arParams["USE_CAPTCHA"] == "Y")
{
$captcha_code = $_POST["captcha_sid"];
$captcha_word = $_POST["captcha_word"];
$cpt = new CCaptcha();
$captchaPass = COption::GetOptionString("main", "captcha_password", "");
if (strlen($captcha_word) > 0 && strlen($captcha_code) > 0)
{
if (!$cpt->CheckCodeCrypt($captcha_word, $captcha_code, $captchaPass))
$arResult["ERROR_MESSAGE"][] = GetMessage("MF_CAPTCHA_WRONG");
}
else
$arResult["ERROR_MESSAGE"][] = GetMessage("MF_CAPTHCA_EMPTY");
}
if($_FILES['file']['size'] < 10485760)
{
$filePath = $_FILES['file']['tmp_name'];
$fileId = CFile::SaveFile(
array(
"name" => $_FILES['file']['name'],
"size" => $_FILES['file']['size'],
"tmp_name" => $filePath,
"old_file" => "0",
"del" => "N",
"MODULE_ID" => "",
"description" => "",
),
'mails',
false,
false
);
}
else
{
$arResult["ERROR_MESSAGE"][] = GetMessage("MF_SIZ_IMG");
}
if(empty($arResult["ERROR_MESSAGE"]))
{
$arFields = Array(
"AUTHOR" => $_POST["user_name"],
"AUTHOR_EMAIL" => $_POST["user_email"],
"EMAIL_TO" => $arParams["EMAIL_TO"],
"TOPIC" => $_POST["user_topic"],
"TITLE_MESSAGE" => $title_message_assess." ".$title_message,
"TEXT" => $_POST["MESSAGE"],
);
if(!empty($arParams["EVENT_MESSAGE_ID"]))
{
foreach($arParams["EVENT_MESSAGE_ID"] as $v)
if(IntVal($v) > 0)
CEvent::Send($arParams["EVENT_NAME"], SITE_ID, $arFields, "N", IntVal($v), $fileId);
CFile::Delete($fileId);
}
else
CEvent::Send($arParams["EVENT_NAME"], SITE_ID, $arFields, $fileId);
$_SESSION["MF_NAME"] = htmlspecialcharsbx($_POST["user_name"]);
$_SESSION["MF_EMAIL"] = htmlspecialcharsbx($_POST["user_email"]);
LocalRedirect($APPLICATION->GetCurPageParam("success=".$arResult["PARAMS_HASH"], Array("success")));
}
Answer the question
In order to leave comments, you need to log in
It's hard to understand from this code snippet, you need to see the whole code.
The first thing that catches your eye:
else
CEvent::Send($arParams["EVENT_NAME"], SITE_ID, $arFields, $fileId);
var_dump($fileId);
//или
print_r($fileId);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question