8 – General error: 2 File ‘/code/sites/default/files/myfile/myfile.csv’ not found (Errcode: 2) insert csv record in DB

I am getting an error while inserting CSV records in the database. It was working fine before, but now it doesn’t. I am using MySQL 10.0.23-MariaDB-log.

DrupalCoreDatabaseDatabaseExceptionWrapper: SQLSTATE(HY000): General error: 2 File ‘/code/sites/default/files/myfile/myfile.csv’ not found (Errcode: 2): LOAD DATA LOCAL INFILE ‘/code/sites/default/files/myfile/myfile.csv’ INTO TABLE pantheon.tablename FIELDS TERMINATED BY ‘,’ ENCLOSED BY ‘”‘ LINES TERMINATED BY ‘ ‘ IGNORE 1 ROWS; Array ( ) in DrupalmodulenameFormmyUploadForm->submitForm() (line 56 of /code/modules/custom/modulename/src/Form/myUploadForm.php).

This the code causing the error.

$database = Drupal::database();
$query = $database->query("TRUNCATE TABLE tablename");
$query = $database->query("LOAD DATA LOCAL INFILE '$file_server_path'
  INTO TABLE `pantheon`.`tablename`
  FIELDS TERMINATED BY ','
  ENCLOSED BY '"'
  LINES TERMINATED BY 'n'
  IGNORE 1 ROWS");