Reputation: 129
I want restrict uploading file in fileInput in Shiny but if I use parameter accept like
fileInput("file_input","Choose your file",accept =".csv")
so I can upload all type file like txt.
Is it any choice how to accept uploading only csv? Thank you.
Upvotes: 1
Views: 561
Reputation: 1573
You may write comma seperated values inside a txt file, that's why it gives you a possibility to upload txt probably.
But you can do something like this on the server where you read the file, to cut it's name into pieces by .
symbol, and check if the last piece (which is it's extension) is the extension you need:
name1 <- strsplit(input$file_input$name, split = ".", fixed = TRUE)[[1]]
if (name1[length(name1)] == "csv") {
# ... do something
} else {
# throw an error
}
Upvotes: 2