title: Upload CSV file to MySQL using Laravel
body: <p>I'm trying to upload a <code>csv</code> file to the table <code>users</code> in Laravel. </p>
  
  <p>This is my <code>php</code> script:</p>
  
  <pre><code>private function _import_csv($path, $filename)
      {
  
          $csv = $path . $filename;
          $query = sprintf("LOAD DATA local INFILE '%s' INTO TABLE users FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' ESCAPED BY '\"' LINES TERMINATED BY '\\n' IGNORE 0 LINES (`firstname`, `lastname`, `username`, `gender`, `email`, `country`, `ethnicity`, `education`  )", addslashes($csv));
      return DB::connection()-&gt;getpdo()-&gt;exec($query);
  
  }
  
  
  
  public function uploadUsers(){
  
  
      if (Input::hasFile('fileInput')){
  
          $file = Input::file('fileInput');
          $name = time() . '-' . $file-&gt;getClientOriginalName();
  
          $path = 'public/uploads/'.date('Y/m/');
  
          $file-&gt;move($path, $name);
          $this-&gt;_import_csv($path, $name);
  
      }
  
      return Response::json(["success"=&gt;true]);
  }
  </code></pre>
  
  <p>But I'm getting this error:</p>
  
  <pre><code>{"error":{"type":"ErrorException","message":"PDO::exec(): LOAD DATA LOCAL INFILE forbidden","file":"C:\\wamp\\www\\lc2\\laravel\\app\\controllers\\UsersController.php","line":224}}
  </code></pre>
  
  <p>I don't know whats wrong. Can anybody please help me?</p>