So, I wanna to get file path and then insert that into mysql.
This is the code:
<?php
$file = $_FILES['file']['tmp_name'];
include "config.php";
$result = mysql_query("LOAD DATA LOCAL INFILE '$file'" .
" INTO TABLE ponuda FIELDS TERMINATED BY ' '");
if (!$result) {
die("Could not load. " . mysql_error());
}
?>
This is the path I receive:
string 'C:\Users\xxx\AppData\Local\Temp\php11EF.tmp'
But, I got mysql error saying this:
Could not load. Can't find file 'C:UsersxxxAppDataLocalTempphp1FA6.tmp'.
Why are slashes removed? What I doing wrong. Tried to search for a problem but didn't find any results.
p.s. I want to upload that file from my local PC.
EDIT: if I change "\" to this "/" in path it works well, but how can I use original file path, not temp one because that file doesn't exist in temp?
OK, managed to find error.
Now it's working:
<?php
$file = str_replace("\\", "/", $_FILES['file']['tmp_name']);
include "config.php";
$result = mysql_query("LOAD DATA LOCAL INFILE '$file'" .
" INTO TABLE ponuda FIELDS TERMINATED BY ' '");
if (!$result) {
die("Could not load. " . mysql_error());
}
?>