文件无法通过PHP上传到MySQL

I have a problem in executing the following query:

    $csv = $path . $filename;
    $query = sprintf("LOAD DATA local INFILE '%s' INTO TABLE users FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' ESCAPED BY '\"' LINES TERMINATED BY '\
' IGNORE 1 LINES (`firstname`, `lastname`, `username`, `gender`, `email`, `country`, `ethnicity`, `education`  )", addslashes($csv));
    return DB::connection()->getpdo()->exec($query);

It works perfectly in Localhost. When I tried it in my server, the following error occurred:

{"error":{"type":"PDOException","message":"SQLSTATE[42000]: Syntax error or access violation: 1148 The used command is not allowed with this MySQL version","file":"\/var\/www\/vhosts\/xxxxxxxx.com\/httpdocs\/xxxxxxxx.com\/app\/controllers\/UsersController.php","line":224}}

I changed the value of local-infile=1 in the my.cnf file. Still, getting the same error.

What might be the problem?

You probably have to enable this in the my.cnf file and for php PDO.

[mysqld]
local-infile 

[mysql]
local-infile 

and ...

<?php
$pdo = new PDO($dsn, $user, $password, 
    array(PDO::MYSQL_ATTR_LOCAL_INFILE => true)
);