Are there any security considerations to keep in mind when using the "LOAD DATA LOCAL INFILE" command in PHP?

When using the "LOAD DATA LOCAL INFILE" command in PHP, it is important to ensure that the file being loaded is from a trusted source to prevent potential security risks such as SQL injection attacks. One way to mitigate this risk is to sanitize the file path before using it in the query to ensure that it only contains valid characters and does not allow for any malicious input.

// Sanitize the file path before using it in the query
$filePath = filter_var($_POST['file_path'], FILTER_SANITIZE_STRING);

// Use the sanitized file path in the query
$query = "LOAD DATA LOCAL INFILE '" . $filePath . "' INTO TABLE my_table";
mysqli_query($connection, $query);