<?php
session_start();
include_once('lib_main.php');
foreach($_GET as $campo => $valor){${$campo}=trim($valor);} 
foreach($_POST as $campo => $valor){${$campo}=trim($valor);} 


$dom = new DOMDocument();
     $dom->encoding = 'utf-8';
     $dom->xmlVersion = '1.0';
     $dom->formatOutput = true;

$response=$dom->appendChild($dom->createElement("response"));
$msgswal=$response->appendChild($dom->createElement("msgswal")); 
     $msgswal->setAttribute("id","msgswal");

if(empty($tabla))
     {
          $msgswal->appendChild($dom->createElement("icon","error")); 
          $msgswal->appendChild($dom->createElement("title","Error")); 
          $msgswal->appendChild($dom->createElement("text","Maestro NO VALIDO")); 
     }
elseif(empty($codigo))
     {    
          $msgswal->appendChild($dom->createElement("icon","error")); 
          $msgswal->appendChild($dom->createElement("title","Error")); 
          $msgswal->appendChild($dom->createElement("text","Código NO VALIDO")); 
     }
elseif(empty($_FILES['xfile']['name']))
     {    
          $msgswal->appendChild($dom->createElement("icon","error")); 
          $msgswal->appendChild($dom->createElement("title","Error")); 
          $msgswal->appendChild($dom->createElement("text","Archivo NO VALIDO")); 
     }
else
     {
          $msgswal->appendChild($dom->createElement("timer","3000")); 
          $msgswal->appendChild($dom->createElement("icon","success")); 
          $msgswal->appendChild($dom->createElement("title","Archivo Cargado")); 
          $msgswal->appendChild($dom->createElement("text",$codigo.' = '.($_FILES['xfile']['name']))); 
     }
echo $dom->saveXML();


// echo '<result>';
// echo '<consolelog>';
// echo '<br>*/*/*/*';     
// echo $_POST['fecha1'];
// echo '<br>*/*/*/*';     
// // print_r($_FILES);
// echo '====:'.count($_FILES['xfile']['name']);

// 	$n_original=$_FILES['xfile']['name'][0];
// 	$n_tempo=$_FILES['xfile']['tmp_name'][0];
  
//    echo '<hr>';
//    echo ' Archivo : '.$n_original.'<br><br>';
  
// //      if($_FILES['ffile']['type']=='text/plain')
//      {$file=file_get_contents($n_tempo);}
// echo '<br>*/*/*/*';     
// echo $file;

// echo '<br>*/*/*/*';     
// echo $_FILES['xfile']['name'][0];
// echo '<br>*/*/*/*';     
// echo $_FILES['xfile']['name'][1];
// echo '<br>*/*/*/*';     
// echo $_FILES['xfile']['name'][2];
// echo '<br>*/*/*/*';     
// echo $_FILES['xfile']['tmp_name'];
// echo '</consolelog>';
// echo '</result>';
     
?>