How can PHP determine whether the LOCAL parameter is needed for the SQL command LOAD DATA INFILE?

To determine whether the LOCAL parameter is needed for the SQL command LOAD DATA INFILE, you can check if the file path is a local file path or a remote file path. If the file path starts with "http://" or "https://", then the LOCAL parameter is not needed. However, if the file path is a local file path on the server, then the LOCAL parameter is required.

$file_path = 'path/to/local/file.csv';

if (strpos($file_path, 'http://') === 0 || strpos($file_path, 'https://') === 0) {
    $load_query = "LOAD DATA INFILE '$file_path' INTO TABLE table_name";
} else {
    $load_query = "LOAD DATA LOCAL INFILE '$file_path' INTO TABLE table_name";
}

// Execute the SQL query using the $load_query variable