I am working on uploading CSV/XLS file.
For that, I am using the following regex to check whether the uploaded file is CSV or XLS
var regex = /^([a-zA-Z0-9s_\.-:])+(.csv)$/;
if(regex.test(fileUpload.value.toLowerCase())) {
//some logic
}
var regex1 = /^([a-zA-Z0-9s_\.-:])+(.xls|.xlsx)$/;
if(regex1.test(fileUpload.value.toLowerCase())) {
//different logic
}
Now , before I upload CSV/XLS , first I am downloading that CSV/XLS and making some changes to and upload it.
So if I have downloaded xyz.csv file, made some changes, and upload it.
After some time , I have again downloaded xyz.csv file , which stores ad xyz (1).csv in my system.
Now, when I tried to upload that CSV file it is showing me invalid CSV because of the space and number in the name of the file.