R
R
Ruslan Absalyamov2018-07-23 16:55:43
1C-Bitrix
Ruslan Absalyamov, 2018-07-23 16:55:43

How to attach a CFile::SaveFile file?

I need a file that the file was converted from html to pdf by file_put_contents to send to the mail with the document attached.
The files documentation says that I should use CFile. I started using it

$output = $dompdf->output();
file_put_contents($_SERVER['DOCUMENT_ROOT'].'/upload/payment/'.$_GET['ORDER_ID'].'.pdf', $output);

$file = CFile::SaveFile(
    $output,
    $_SERVER['DOCUMENT_ROOT'].'/upload/payment/'.$_GET['ORDER_ID'].'.pdf',
    false,
    false
);

And it doesn't work for me, who can tell me how to push the file into sending mail?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ruslan Absalyamov, 2018-07-24
@rusline18

$file = CFile::MakeFileArray(
    $_SERVER['DOCUMENT_ROOT'].'/upload/payment/'.$_GET['ORDER_ID'].'.pdf',
    false,
    false,
    ''
);

$fileSave = CFile::SaveFile(
    $file,
    '/payment',
    false,
    false
);

CEvent::Send(
    'SEND_PAY_PDF',
    's1',
    array('EMAIL_TO' => $USER->getEmail()),
    'N',
    '',
    array($fileSave),
    'ru'
);

A
Alexey Emelyanov, 2018-07-23
@babarun

First, tell me if the file itself is saved?
Use the file id received in the previous step to send an email using this method: https://dev.1c-bitrix.ru/api_help/main/reference/c...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question