title: How to upload CSV to wordpress custom table
body: <p>How to upload CSV data to wordpress custom table wp_sonali_data. Bellow is the code what I'm trying. But no luck please help</p>
  
  <p><strong>Here is my custom table column</strong> </p>
  
  <pre><code>id
  brcode
  brname
  dist
  </code></pre>
  
  <p><strong>Here is my uploader</strong></p>
  
  <pre><code>   &lt;form method="post" action=""&gt;
  &lt;p&gt;Choose your CSV file&lt;/p&gt;&lt;br /&gt;
  &lt;input type="file" name="file" /&gt;
  &lt;input type="submit" name="submit" value="submit"/&gt;
  
  &lt;/form&gt;
  
  
  &lt;?php
  
      //Upload CSV File
      if (isset($_POST['submit'])) {
  
      global $wordpress,$wpdb;
          $datafile= $_FILES['file']['tmp_name'];
          $file=$upload_dir['basedir'].'/'.$_FILES['file']['name'];
          $fileurl=$upload_dir['baseurl'].'/'.$_FILES['file']['name'];
          if (!move_uploaded_file($_FILES['file']['tmp_name'],$file)){
              print_r('Failed to move uploaded file.');
              }
          $sql="
          LOAD DATA LOCAL INFILE '".$fileurl."' INTO TABLE wp_sonali_data
          FIELDS TERMINATED BY ',' 
          LINES TERMINATED BY '\r\n'
          (id,brcode,brname,dist);
          ";
          $query = $wpdb-&gt;query($sql);
  }
  </code></pre>
  
  <p><strong>Error</strong></p>
  
  <pre><code>Output: 'Failed to move uploaded file.'
  </code></pre>