I have created a file select functionality that allows the user to select a .csv
files. Code is below:
<input type="file" accept=".csv" ref="file" v-on:input="handleFileUpload()" id="upload-photo" />
This enables the user to browse for .csv files and my problem is, if the user select the all files, all files are displayed and can select other file types.
How can I disable the all files option or check the file extension using vue.js. Below is the functionality if the user selects the file.
onConfirm() {
this.txtBrowse = this.file.name; //gets the file name with the extension
//other functionalities
}
UPDATE
As of the moment, I temporarily used the following trapping:
if(this.file.name.split(".").pop() != 'csv'){//check if file extension is csv
Vue.alert.show( "Please select CSV file type", "error");
return;
}
But, if you have a better approach, please help me out.