I'm trying to open a file and IMPORT it to PSQL
$sql ="COPY r_vehicle_submodel FROM '".$filePath."' DELIMITER ',' CSV";
However it display me error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[58P01]: Undefined file: 7 ERROR: could not open file "C:\xampp...\uploads\SearchTreeCZ.csv" for reading: No such file or directory' in
I try to copy this path to clipboard and open file and i open it correctly so file is there for sure.
After that I was thinking if just PHP don't have permission to this file/ folder so I write something really simple:
$file = fopen($filePath,'r');
echo fread($file,filesize($filePath));
Which open me my file correctly, I also try to scandir this path successfully.
echo $filepath
display:
C:\xampp\htdocs\xampp\utilities\searchTreeImport\uploads\SearchTreeCZ.csv
Guys do you have any idea where can be a problem and WHY I can't open this file?
Thanks
EDIT: This QUERY works (MySQL)
$sql = "LOAD DATA INFILE '".$filePath."'
INTO TABLE r_vehicle_submodel
CHARACTER SET UTF8
FIELDS TERMINATED BY ','
ENCLOSED BY '\"'
IGNORE 1 LINES ";
This QUERY doesn't work (PSQL)
$sql ="COPY r_vehicle_submodel FROM '".$filePath."' DELIMITER ',' CSV";
So i expect problem can be in my $sql query