Currently I am using the solution provided by this answer in my file upload page. But using the solutions here I found that when the file type is switched to All files, all files of any type is shown and able to upload. (I mean once we clicked the file upload button window is appeared showing our local directories. There is an option at the bottom right corner to change the file type) How do I prevent it?
Asked
Active
Viewed 27 times
1 Answers
0
Finally found this Javascript function which works fine.
var fl = document.getElementById('file');
fl.onchange = function(e){
var ext = this.value.match(/\.(.+)$/)[1];
switch(ext)
{
case 'mp4':
case 'mov':
case 'mpg':
case 'avi':
alert('allowed');
break;
default:
alert('not allowed');
this.value='';
}
};

sndu
- 933
- 4
- 14
- 40