Я пытаюсь создать XML-файл, а затем отправить его как электронную почту, а также принудительно загрузить, проблема в том, что XML-документ содержит несколько случайных чисел на конец его, делая его бесполезным.DOMDocument создает конечные данные в XML
Код:
header('Content-Disposition: attachment;filename=License.xml');
header('Content-Type: text/xml');
$document = new DOMDocument('1.0');
$document->formatOutput = true;
$element_account = $document->createElement("Account");
$attr_name = $document->createAttribute("Username");
$attr_pass = $document->createAttribute("Password");
$attr_key = $document->createAttribute("Key");
$attr_name->value = $user;
$attr_pass->value = $pass;
$attr_key->value = $key;
$element_account->appendChild($attr_name);
$element_account->appendChild($attr_pass);
$element_account->appendChild($attr_key);
$document->appendChild($element_account);
$file_to_attach = 'tmp/License'.$user.'.xml';
$document->save($file_to_attach);
require '../PHPMailer/PHPMailerAutoload.php';
$pemail = new PHPMailer();
$pemail->From = '[email protected]';
$pemail->FromName = 'OGServer Licensing';
$pemail->Subject = 'Your OGServer License has arrived!';
$pemail->Body = 'Thank you for registering your product, you will find your License attached to the e-mail, if you have any questions about how to set up your license, you can view the tutorial here: http://ogserver.net/licensing/tutorial.html';
$pemail->AddAddress($email);
$pemail->AddAttachment($file_to_attach, 'License.xml');
$pemail->Send();
$filepath = realpath($file_to_attach);
echo readfile($file_to_attach);
Вы имеете в виду цифры, сгенерированные автоматически? –
Я бы предположил, что в конце моего файла есть всего несколько случайных чисел (обычно три из них), они разные, каждый раз, когда я создаю файл. – Hobbyist
Можете ли вы просто опубликовать/URL-адрес вашего образца XML? –