Hi I badly need you help.
Error showing after importing .CSV file using mysql load data infile.
I have a form upload below which working fine
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>
and a PHP upload script using load data infile.
require("../config/conn.php");
if (is_uploaded_file($_FILES['my-file']['tmp_name']) && $_FILES['my-file']['error']==0) {
$path = 'C:/xampp/htdocs/dom/test/uploads/' . $_FILES['my-file']['name'];
if (!file_exists($path)) {
if (move_uploaded_file($_FILES['my-file']['tmp_name'], $path)) {
echo $mysql = "LOAD DATA LOCAL INFILE '".$_FILES['my-file']['name']."'
REPLACE INTO TABLE table
FIELDS
TERMINATED BY ','
LINES
TERMINATED BY '\\n'
IGNORE 1 LINES
(`col1`,`col2`,`col3`,`col4`,`col5`....)";
$query = mysqli_query($link, $mysql) or die(mysqli_error($link));
if(!$query)
{
printf("Error message: %s\n", mysqli_error($link));
}
} else {
echo "The file was not uploaded successfully.";
}
} else {
echo "File already exists. Please upload another file.";
}
} else {
echo "The file was not uploaded successfully.";
echo "(Error Code:" . $_FILES['my-file']['error'] . ")";
}
Everything is fine, except the load data local infile cannot see the right path. please see the error: Can't find file 'logJan262013.CSV'. but the .csv file is uploaded successfully in folder 'uploads/'. Any help would be appreciated.
thanks alot!
['name']
directly in filesystem operations). – Marc B