Ok funziona! L'unico problema che mi resta, è che mi sovrascrive il file xml piuttosto che aggiornarlo con la lista.
La riga non me l'aggiunge, me la sostituisce.
Che si fa? :_) grazie!
Ecco il codice php:
<?php
function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return "";
} $l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext; }
if(isset($_POST['Submit'])) {
$image=$_FILES['image']['name'];
if ($image) {
$filename = stripslashes($_FILES['image']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")){
echo '<h1>Puoi inserire solo jpg</h1>';
$errors=1;
}else{
$image_name=time().'.'.$extension;
$newname="image_files/".$image;
$copied = copy($_FILES['image']['tmp_name'], $newname);if (!$copied) {
echo '<h1>Copy unsuccessfull!</h1>';
$errors=1;}}}}
if(isset($_POST['Submit']) && !$errors) { echo "<h1>Immagine salvata</h1>"; }
$nodo_xml .= "<pic>
<image>$image</image>
</pic>
";
$inizio_xml = "
<images>
";
$chiusura_xml = "
</images>
";
$xml = $inizio_xml.$nodo_xml.$chiusura_xml;
$handle = fopen("images.xml", "w");
fwrite($handle, $xml);
fclose($handle);
?>
<form name="newad" method="post" enctype="multipart/form-data" action="">
<table>
<tr><td><input type="file" name="image"></td></tr> <tr><td>
<input name="Submit" type="submit" value="Upload image"></td></tr>
</table>
</form>