FileFormat
FileFormat[source] attempts to determine what Import format could be used to import the file.
FileFormat[source, {fmt1, fmt2, ...}] returns the first format that can be used.
Examples
Detect file format:
FileFormat["image.png"]
(* "PNG" *)Check from multiple formats:
FileFormat["data.csv", {"CSV", "TSV", "JSON"}]
(* "CSV" *)Please visit the official Wolfram Language Reference for more details.