Are you near your boiling point when using the MySQL LOAD_FILE function from a PHP script, here is the solution.
You already debugged the file uploads, file movements, renaming and so on, nothing worked.
$sql = "INSERT INTO myFiles (id, thefile) VALUES ('1', LOAD_FILE('/tmp/somefile'))";
The above query might give you a headache because it appears to be ok, and guess what, it is!
Me and my colleague were repeatedly struggling with the fact the query didn’t worked from PHP but did work from our MySQL manager tool.
I do hear you thinking, huh, how is that possible? Well we’re using the user ‘root’ in our manager tool which have all privileges of course. Now some of you will have a blinking light now.
It seems so simple, but the majority of the MySQL users doesn’t have this by default.
GRANT FILE ON *.* TO 'someuser'@'somehost'; FLUSH PRIVILEGES;