Reputation: 1308
If I upload .exe or .twbx files then it show the alert message like you could not these type of files using angular 4 in typescript.
Upvotes: 2
Views: 6022
Reputation: 127
You can use following code snippet to allow required formats
<input type="file" accept=".xls,.xlsx" />
Source: Limit file format when using <input type="file">?
Upvotes: 4
Reputation: 224
Please try this.It works for me.
var regexp;
var extension = fileName.substr(fileName.lastIndexOf('.'));
if ((extension.toLowerCase() == ".exe") ||
(extension.toLowerCase() == ".twbx"))
{
alert("Could not allow to upload .exe and .twbx files");
}
Upvotes: 3