Problem in uploading .xml file

Good day!

I have code for uploading the files with the extension name .xml, after it was upload it will display in webpage and also save to database…

My problem is during on my testing …When I upload .xml file it did not upload, No error displayed…Sometimes when I upload it will upload, but theres a .xml file that did not upload, I cannot configured why it happens.

here is the code:


<?php
$data = array();


$con = mysql_connect("localhost", "root","");
if (!$con) { 
  die(mysql_error());
}
$db = mysql_select_db("hris", $con);
if (!$db) { 
  die(mysql_error());
}

$sql = "select * from attendance";
$result =  mysql_query($sql, $con);
if (!$result) {
    die(mysql_error());
}
$total = mysql_num_rows($result);
if ($total > 0) {
    $sql = "delete from attendance";
    $result =  mysql_query($sql, $con);
    if (!$result) {
        die(mysql_error());
    }
}
  
function add_employee($EMP_NO, $Lastname, $Firstname, $Middlename, $Date, $Time)
  {
      global $data; 
      
      $con = mysql_connect("localhost", "root","");
      if (!$con){ die(mysql_error());}
      $db = mysql_select_db("hris", $con);
      if (!$db) { 
          die(mysql_error());
      }

      $EMP_NO = $EMP_NO;
      $Lastname = $Lastname;
      $Firstname = $Firstname;
      $Middlename = $Middlename;
      $Date = substr($Date,0,-13);
      $Time = substr($Time,11,-4);

      $Time = strftime('%I:%M %p', strtotime($Time));


           
      $sql = "INSERT INTO attendance (EMP_NO, Lastname, Firstname, Middlename, Date, Time) VALUES ('$EMP_NO', '$Lastname', '$Firstname', '$Middlename', '$Date', '$Time')";
      mysql_query($sql, $con);
      
   
      $data []= array('EMP_NO' => $EMP_NO, 'Lastname' => $Lastname, 'Firstname' => $Firstname, 'Middlename' => $Middlename, 'Date' => $Date, 'Time' => $Time);
      
  }
  
  if ( $_FILES['file']['tmp_name'] )
  {
      $dom = DOMDocument::load( $_FILES['file']['tmp_name'] );
              
      $rows = $dom->getElementsByTagName( 'Row' );
      global $last_row;
      $last_row = false;
      $first_row = true;
      foreach ($rows as $row)
      {
          if ( !$first_row )
          {
             
              $EMP_NO = "";
              $Lastname = "";
              $Firstname = "";
              $Middlename = "";
              $Date = "";
              $Time = "";
              
              
              $index = 1;
              $cells = $row->getElementsByTagName( 'Cell' );
          
              foreach( $cells as $cell )
              { 
                  $ind = $cell->getAttribute( 'Index' );
                  if ( $ind != null ) $index = $ind;
                  
                  if ( $index == 1 ) $EMP_NO = $cell->nodeValue;
                  if ( $index == 2 ) $Lastname = $cell->nodeValue;
                  if ( $index == 3 ) $Firstname = $cell->nodeValue;
                  if ( $index == 4 ) $Middlename = $cell->nodeValue;
                  if ( $index == 5 ) $Date = $cell->nodeValue;
                  if ( $index == 6 ) $Time = $cell->nodeValue;
                  $index += 1;
              }
         
              if ($EMP_NO=='' and $Lastname=='' and $Firstname=='' and $Middlename=='' and $Date=='' and $Time=='') {
                    $last_row = true;
              }      
              else {
                  
                    add_employee($EMP_NO, $Lastname, $Firstname, $Middlename, $Date, $Time);
              }      
          }
          if ($last_row==true) {
              $first_row = true;
          }     
          else {
              $first_row = false;
          }
      }
  }
  ?>
  
  <html>
  <body>
  <table>
  <tr>
      <th>Employee Attendance</th>
  </tr>

  <?php foreach( $data as $row ) { ?>
  <tr>
  <td><?php echo( $row['EMP_NO'] ); ?></td> 
  <td><?php echo( $row['Lastname'] ); ?></td>
  <td><?php echo( $row['Firstname'] ); ?></td>
  <td><?php echo( $row['Middlename'] ); ?></td>
  <td><?php echo( $row['Date'] ); ?></td>
  <td><?php echo( $row['Time'] ); ?></td>
  </tr>
  <?php } ?>
  </table>
  </body>
 </html>

Thank you

How big are these files? You might be hitting the filesize limit.

the filesize is 6,972kb

but here is my upload code


<html>
<body>
<form enctype="multipart/form-data" 
  action="import_att.php" method="post">
  <input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
  <table width="600">
  <tr>
  <td>Employee Attendance:</td>
  <td><input type="file" name="file" /></td>
  <td><input type="submit" value="Upload" /></td>
  </tr>
  </table>
  </form>
  </body>
 </html>

So. 6972 * 1024 = 7,139,328…

<input type=“hidden” name=“MAX_FILE_SIZE” value=“2000000” />

2,000,000 vs 7,139,328…

Yep. Think you might need to check your math there a bit.

So you mean I need to change thee value of my max_file_size???
Thank you