title: Using LOAD DATA INFILE in perl to insert values in MYSQL
body: <p>I am trying to upload CSV file in to a mysql database using perl. My perl script will reside on a server, which I will access through my browser. In the browser, there will be an option to upload a file.</p>
  
  <p>Question is, how exactly I am gonna do this </p>
  
  <ol>
  <li>Do I need to save that file somewhere on the server and then use it ?</li>
  <li>Can I directly use the file from my laptop by giving a fixed path ?</li>
  </ol>
  
  <p>so far I tried doing this </p>
  
  <pre><code>if($update eq "fullLoad"){
  $filename =  param("customPricing");
  
  
  my $upload_filehandle = upload("customPricing"); 
  open ( UPLOADFILE, "&gt;$filename" ) or die "$!"; 
  
  binmode UPLOADFILE; 
  while ( &lt;$upload_filehandle&gt; )
  {
      print UPLOADFILE; 
  } 
  close UPLOADFILE; 
  
  
  $query = "LOAD DATA INFILE '\bigmac\bm_src\html\cgi-bin\testbrocade\$filename' INTO TABLE customPricingTest FIELDS TERMINATED BY ','";
  $sth = $dbh-&gt;do($query) or die "SQL Error: $DBI::errstr\n"; 
  
  print $sth . "Records Uploaded &lt;br/&gt;";
  </code></pre>
  
  <p>}</p>
  
  <p>Edited --> Above code is throwing error Access Denied for user . I am successfully able to create the file on the server but looks like I am getting error accessing it..Any ideas ?</p>
  
  <p>Thanks,
  Nitesh</p>