3

I'm working with an existing shiny app designed to take in a csv file as input. I'd like to expand on the functionality of the app to let it take both csv files and xlsx files as input, however, I'm not clear on what values to use for fileInput's accept parameter. This is what is currently contained in the accept parameter:

accept = c('text/csv', 'text/comma-separated-values,text/plain', '.csv')

Firstly, I'm not clear on why all three values are needed, and would appreciate clarification on why each is there. Secondly, how can I let the app take in xlsx files correctly? I can get it to take in xlsx files like this:

accept = c('text/csv', 'text/comma-separated-values,text/plain', '.csv', 'xlsx')

However, since three strings were being used for csv files, I'm unsure if I will be missing functionality using only one string for xlsx files. Is there a better way to implement this?

J0HN_TIT0R
  • 293
  • 1
  • 8

1 Answers1

1

From the source code for fileInput:

\item{accept}{A character vector of MIME types; gives the browser a hint of what kind of files the server is expecting.}

This answer gives a good explanation of what MIME types are and how they are used.

This list of MIME types indicates that application/vnd.ms-excel is used with the .xls extension and application/vnd.openxmlformats-officedocument.spreadsheetml.sheet is used with .xlsx.

Hallie Swan
  • 2,364
  • 1
  • 9
  • 16