I am trying to upload a csv file into my mysql database from php code. I am getting an error: "Could not updated:The used command is not allowed with this MySQL version"
This is the code I am using. Do i have to give any kinds of permissions so that I am able to do it from php forms.? As I am able to load this same csv file from mysql directly from terminal.
P.S.:- I have changed my.cnf file after reading this post. MySQL: Enable LOAD DATA LOCAL INFILE
How ever i am unable to upload from phpmyadmin and from php forms. Error Message is same. i.e. "Could not updated:The used command is not allowed with this MySQL version"
Below is the piece of code.
if(@$_POST['submit'])
{
$file = $_FILES['file'];
$name = $file['name'];
$type = $file['type'];
$size = $file['size'];
$tmppath = $file['tmp_name'];
echo "Name of the file is $name <br> $tmppath";
if($name!="")
{
echo "<br> Trying to upload file <br>";
if(move_uploaded_file($tmppath, "csvfiles/.$name")) //project is a folder in which you will save csv files
{
$query="LOAD DATA LOCAL INFILE '$tmppath' INTO TABLE test.metadata FIELDS TERMINATED BY ';' LINES TERMINATED BY '\n' IGNORE 1 LINES;";
mysql_query ($query) or die ('Could not updated:'.mysql_error());
echo "CSV file inserted successfully !!<br>";
}else {echo "<br>Failed !!!!";}
}else {echo "<br>No file exist <br>";}
}else {echo " <br> No file exist <br>";}