0

I am working on preexisting code which allows users to import csv files. I am trying to understand how the code works with some csv files but it fails at this condition:

if ($data['file']->getClientMimeType() == 'application/vnd.ms-excel') {

How can I set the mimetype of my csv file? How do I access the header of my csv file to set it?

John Kary
  • 6,703
  • 1
  • 24
  • 24
bulbici
  • 13
  • 1
  • 4
  • 2
    Possible duplicate of [What MIME type should I use for CSV?](https://stackoverflow.com/questions/7076042/what-mime-type-should-i-use-for-csv) – david Jul 26 '18 at 08:05
  • You must set it not for file, but for request. (at least I think so) – revengeance Jul 26 '18 at 08:11

1 Answers1

0

As per my understading Please try to implement this..

   getClientMimeType() == 'text/csv'

Also You can also check All/Specific type of mime types from this link(If you need any).

   https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types 
deep bhatt
  • 27
  • 1
  • 9