title: Import .sql file via PHP upload
body: <p>I working on doing a file upload in-order to restore a backup table (.sql format)...
  The code below is for uploading the .sql file :</p>
  
  <pre><code>&lt;form enctype="multipart/form-data" method="post"&gt;
  
  &lt;font style="font-size:18px;"&gt;File to import:&lt;/font&gt;&lt;br /&gt;
  
  &lt;input size='30' type='file' name='filename'&gt;
  
  &lt;input type="submit" name="submit" value="Upload File"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>After doing a submit, the following codes are :</p>
  
  <pre><code>set_time_limit ( 0 );
  
     //Upload File 
      if (isset($_POST['submit'])) { 
         if (is_uploaded_file($_FILES['filename']['tmp_name'])) { 
      if (move_uploaded_file($_FILES['filename']['tmp_name'], $_FILES['filename']['name'])) {
  
  
  
  $dbhost = 'localhost';
  $dbuser = 'root';
  $dbpass = '';
  $conn = mysql_connect($dbhost, $dbuser, $dbpass);
  if(! $conn )
  {
    die('Could not connect: ' . mysql_error());
  }
  $table_name = "items";
  
  $backup_file = $_FILES['filename']['name'];
  
  if(!file_exists($backup_file)){
      echo "File Not Exists";
  }
  
  $sql = "LOAD DATA INFILE '$backup_file' INTO TABLE $table_name";
  
  mysql_select_db('MM_db');
  $retval = mysql_query( $sql, $conn );
  if(! $retval )
  {
    die('Could not load data : ' . mysql_error());
  }
  echo "Loaded  data successfully\n";
  mysql_close($conn);
  fclose($handle); 
       }
       ?&gt;
       &lt;script&gt;
       alert('Items Uploaded Successfully');
       &lt;/script&gt;
       &lt;?php  
  exit();
         }
      }
  </code></pre>
  
  <p>When doing the upload , I receive this error :</p>
  
  <pre><code>Could not load data : File 'c:\wamp\bin\mysql\mysql5.5.24\data\MM_db\items.sql' not found (Errcode: 2)
  </code></pre>
  
  <p>Its like it did not find my items.sql file, although I've checked if its there or not by doing <code>file_exists($backup_file)</code>, but still I'm facing this problem. I think there might be something missing with the file upload code?</p>