Topic: Post -> File and use it in function.

I need to upload a file and use it in a function, I'm having some troubles, though.

Here is my code.

                        <form action="index.php" id="filecsv"  method="post" enctype="multipart/form-data">
                          <input type="file" multiple="multiple" id="file" name="up_csv[]"/><br />
                              //tipos de archivos permitidos
                    $extensioncsv = array('csv', 'txt');
                    //multicargador de archivos
                        for ($j=-1; $j<count($extensioncsv); $j++) {
                            if (strripos($_FILES['up_csv']['name'][$i], $extensioncsv[$j])!== false) {
                            $destino = $ruta.$_FILES['up_csv']['name'][$i];
                            $up_tamanio +=$_FILES['up_csv']['size'][$i];
                           <input type="button" value="Crear" onClick="xajax_makecsv(xajax.getElementById('file'));" />

this my function


$xajax = new xajax(); 

function makecsv($csv) {

$doc = new DOMDocument();

   $row = 1;
   $handle = fopen($csv, "r");
     # Rows Counter
    $csvxrow = file($csv);
    $csvxrow[0] = chop($csvxrow[0]);
    $anzdata = count($csvxrow);
   while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
       $num = count($data);
              #Load Predefined XML Template      
             $xml2 = $xml;
             $xmlruta = './Templates/';
             $xml = $xmlruta.$data[1].'.xml';
             $xp = new DOMXPath($doc);
         for ($c=0; $c < $num; $c++) {
               $name = $data[0] .'-'. $data[1];
               $doc->formatOutput = true;
          echo $doc->saveXML();
               $rutafinal = './XML/';

    echo $anzdata . " XML Creados" . "<br />";  

return $objResponse->save();
return $data;


Any idead ?

Re: Post -> File and use it in function.

File posting doesn't work via the xajax function. We always post the file to a hidden iframe with a target of a PHP file and process that way.  you can then trigger a call to the xajax function if extra processing is required.

Re: Post -> File and use it in function.

My function doesn't return nothing.... I just need to make the function.

Re: Post -> File and use it in function.

If you are trying to return the CSV file to the browser, there is no need for xajax. Just direct link to a program that generates it.