2
votes

I tried to change from insert to to load data infile for uploading a large CSV file.

I explored some examples on how to use load data infile. But it's not working and giving this Error:

SQLSTATE[HY000]: General error: 29 File '/direct1/@tmp/phpFZLLYA' not found (Errcode: 13 "Permission denied").

This is my code:

$target_dir = '/direct1/@tmp/'; 
$target_file = $target_dir . basename($_FILES["file"]["tmp_name"]);

$stmt = $dbcon->prepare("LOAD DATA INFILE '$target_file' INTO TABLE Rain FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 1 LINES(id, date, vol, day)"); 
$stmt->execute();

When I try to change to load data local infile based on related discussion, error code does not appear but the data is not inserted to the database. I am using INNODB storage engine.

1

1 Answers

0
votes

I solved the error by using move_uploaded_file function and the file can be access.