N
N
Nrsimkha2019-12-04 17:57:52
1C-Bitrix
Nrsimkha, 2019-12-04 17:57:52

How to save the generated xml file in the root of the site on Bitrix?

A new xml file is created in the init.php file. It must be saved in the \upload\tmp site folder.
The following code saves the file if you test the code locally on your computer. But when working with Bitrix files, the file is no longer saved.

$dom = new domDocument("1.0", "utf-8");
$root = $dom->createElement("congrats");
$dom->save($_SERVER['DOCUMENT_ROOT']."\upload\tmp\congrats.xml");

The variant using CFile::SaveFile did not help either:
$fileSave = CFile::SaveFile(
    $dom,
    'tmp',
    false,
    false
);

Can anyone tell me how to make this file still appear on the site?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2019-12-04
@anton99zel

$dom->save("/upload/tmp/congrats.xml");
or so (the full path, part of the path can be peeped on the page
/bitrix/admin/site_admin.php?lang=ru in the site settings "Path to the root folder of the web server for this site"
Slash like /

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question