I am running the following piece of code to dump a csv into a database table and I have followed the instructions here to make sure that I am doing it the right way but I keep on getting the following error even though my file exists
File 'http:/localhost/dashboardapp/uploads/admin.csv' not found (Errcode: 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));
}
I am not really sure on how to proceed as i have looked for resources but havent found any yet
感谢您的意见,问题出在所提到的路径上,我使用了codeigniter,所以我使用了FCPATH变量,它起作用了。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.