-1

我有来自文件上传器的这个 PHP 脚本。它正在生成一个 XML 文件,但每次我上传一个新项目时,它都会替换当前节点而不是添加到“树”中。

<?php

$todayDate = $_POST['todayDate'];
$Name = $_POST['Name'];
$Email = $_POST['Email'];
$filename = $_FILES['Filedata']['name'];    
$filetmpname = $_FILES['Filedata']['tmp_name']; 
$fileType = $_FILES["Filedata"]["type"];
$fileSizeMB = ($_FILES["Filedata"]["size"] / 1024 / 1000);

move_uploaded_file($_FILES['Filedata']['tmp_name'], "images/".$filename);



$xml = new XMLWriter;
$xml->openMemory();
$xml->startDocument( '1.0' , 'iso-8859-1' );
$xml->startElement("galeria");
$xml->writeElement("Name", $Name);
$xml->writeElement("Email", $Email);
$xml->endElement();

$file = fopen('data.xml','w+');
fwrite($file, $xml->outputMemory(true));
fclose($file);
4

1 回答 1

2

试试$file = fopen('data.xml', 'a');我认为这是附加文件的正确方法

于 2012-07-27T18:55:38.193 回答