Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommcfarlin/5e9eea5dfa788cd1c52b to your computer and use it in GitHub Desktop.
Save tommcfarlin/5e9eea5dfa788cd1c52b to your computer and use it in GitHub Desktop.
How to check the file type of CSV files across *nix-based systems and Windows-based systems.
<?php
// Read the file from the $_FILES collection
$file = $_FILES['re_csv_file'];
// Check the type of the file to make sure it's a CSV (*nix-based systems, Windows-based systems)
if( 'text/csv' == $file['type'] || 'application/vnd.ms-excel' == $file['type'] ) {
// Parse the CSV...
}
<?php
// Read the file from the $_FILES collection
$file = $_FILES['re_csv_file'];
// Check the type of the file to make sure it's a CSV
if( 'text/csv' == $file['type'] ) {
// Parse the CSV...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment