I am trying to load a CSV file into a mysql database using perl. My perl script will be on a server that I will access through my browser. The browser will be able to download the file.
The question is exactly how am I going to do this
- Do I need to save this file somewhere on the server and then use it?
- Is it possible to directly use the file from my laptop by specifying a fixed path?
so far i tried to do this
if($update eq "fullLoad"){ $filename = param("customPricing"); my $upload_filehandle = upload("customPricing"); open ( UPLOADFILE, ">$filename" ) or die "$!"; binmode UPLOADFILE; while ( <$upload_filehandle> ) { print UPLOADFILE; } close UPLOADFILE; $query = "LOAD DATA INFILE '\bigmac\bm_src\html\cgi-bin\testbrocade\$filename' INTO TABLE customPricingTest FIELDS TERMINATED BY ','"; $sth = $dbh->do($query) or die "SQL Error: $DBI::errstr\n"; print $sth . "Records Uploaded <br/>";
}
Edited β Above code throws an error Access is denied to the user. I can successfully create the file on the server, but it looks like I'm getting an error. Any ideas?
Thanks Nitesh
source share