Hi, I am a newbie to web application and I am facing a problem in uploading a csv file.
This is the input tag that I am using to select a file,
<input id="imprtUpldFileInpt" name="file" type="file"/>

And this is how I process the file details with jQuery,

var file = $("#imprtUpldFileInpt")[0].files[0];
var f_name = file.name;
var f_size = file.size;
var f_type = file.type;
var fileMimeTypeArr = ["text/comma-separated-values", "text/csv", "application/csv", "application/vnd.ms-excel"];
var fileTypePos = $.inArray(f_type, fileMimeTypeArr);

I am checking whether the selected file is a csv or not with the value of fileTypePos. If the value is greater than or equal to 0, then I conform that it is a csv file. But I am facing a problem in getting the file type.

If a csv is selected, the file name and size are obtained correctly. But I am not getting the file type.

This screenshot shows the file details of a csv file.

I have added the possible mime types in fileMimeTypeArr for checking whether the file is a csv file or not. The problem is with getting the file type.

This problem does not occur if the machine has MS Excel installed. But if a csv file is created/saved in a machine that does not have MS Excel, then this problem occurs.

Why the file type has an empty string? Any help would be appreciated.

Since the filename has the .CSV why bother with filetype. Just grab the last 3 letters of the filename if filetype is ""