javascript - How to get the file type of a CSV in jQuery -


this input tag using select file,

<input id="imprtupldfileinpt"  name="file" type="file"/> 

and how process file details 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 checking whether selected file csv or not value of filetypepos. if value greater or equal 0, conform csv file. facing problem in getting file type.

if csv selected, file name , size obtained correctly. not getting file type.

the following screenshot shows file details of csv file, enter image description here

i have added possible mime types in filemimetypearr checking whether file csv file or not. problem getting file type.

this problem not occur if csv file saved in machine has ms excel installed. if csv file created/saved in machine not have ms excel, problem occurs.

why file type has ""?


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -