Many users report that they get this error message:
"The file '/tmp/phpQtLp3j' must be in the database directory or be readable by all"
Your MySQL server cannot access the file. To fix that try:
1. To tune permissions to that folder, for example try (of course if you use Linux) to "chmod" the temp folder by 755 permissions or something like that. If you get 'permission denied for chmod', you are on the right way - just use the root account to do that.
2. If that doesn't help, you will have to copy the file to the mysql data
directory (format like "/[mysql installation path]/data/[database
name]/") and feed my script with this new filename.
The file is that CSV file you want to import to your database.
"To copy it" means that you have to change the code a little - call
copy() function to copy a temporary file (which is created when you
select a file to upload and press Submit) to mysql data directory.
"To feed it to the script" means that you have to set the 'file_name'
option not by the temporary file name, but by the name of file in
mysql data directory (for security reasons you faced).
ariell david - 2013-09-29 14:41:58 - In reply to message 4 from joel
you don't need ANY script at all to solve this problem. Instead, the logical approach is to use SQL itself. Also, it's not a good idea to invoke UNIX commands thru PHP. What if you run into a situation, where the "php user" is prevented from running certain actions on a "bullet-proof" server?
In short English, add the "LOCAL" directive to you SQL, and done:
Like this: "LOAD DATA LOCAL INFILE..."
Make sure you provide the entire (absolute) path to your file - problem solved.