我正在运行以下代码将csv转储到数据库表中,并且我已按照here的说明确保我正在以正确的方式执行此操作,但我仍然继续收到以下错误虽然我的文件存在
文件' http:/localhost/dashboardapp/uploads/admin.csv'没找到(错误代码:2)
$this->db->truncate($this->table_name);
$query_name = "LOAD DATA LOCAL INFILE '"
. $file_path .
"' INTO TABLE `"
. $this->table_name .
"` FIELDS TERMINATED BY ','
LINES TERMINATED BY '\\n'
IGNORE 1 LINES
(@mytimestamp,curr_property,curr_property_cost,day_property,day_property_cost,curr_solar_generating,curr_solar_export,day_solar_generated,day_solar_export,curr_chan1,curr_chan2,curr_chan3,day_chan1,day_chan2,day_chan3)
SET time_stamp=STR_TO_DATE(@mytimestamp, '%d/%m/%Y %h:%i')";
$link = mysqli_init();
if (!$link) {
die('mysqli_init failed');
}
if (!mysqli_options($link, MYSQLI_OPT_LOCAL_INFILE, true)) {
die('Setting MYSQLI_OPT_LOCAL_INFILE failed');
}
if (!mysqli_real_connect($link, 'localhost', 'root', 'rolemodel', 'dashboard')) {
die('Connect Error (' . mysqli_connect_errno() . ') '
. mysqli_connect_error());
}
$result = $link->query($query_name);
if (!$result) {
printf("%s\n", mysqli_error($link));
}
我不确定如何继续,因为我已经寻找资源但尚未找到任何
答案 0 :(得分:0)
感谢评论人员,问题在于提到的路径,我使用了codeigniter所以我使用了FCPATH变量并且它有效。