파일 확장명 만 사용되지만 파일 이름에 마침표가 있거나 확장명이없는 경우 정규식을 사용할 수 없는지 확인하려고합니다. 이것에 대한 도움을 주시면 감사하겠습니다. 감사!업로드하기 전에 파일 이름 확장명을 검사하는 Regex
현재 코드 : 당신이 정규식에 따라하지 않을 경우
// this looks at what file type was attemped and validates it
$('INPUT[type="file"]').change(function() {
var ext = this.value.match(/\.(.+)$/)[1];
switch (ext) {
case 'bmp':
case 'doc':
case 'xls':
$('#publicSubmit').attr('disabled', false);
break;
default:
alert('This is and invalid file extension. Vaild extension(s): bmp, doc, xls');
//$('#publicSubmit').attr('disabled', true);
this.value = '';
}
});
'\. ([^.] +) $ /'를 사용하여 이름에 마침표가있는 파일을 처리하십시오. –
파일 입력 값을 변경할 수 있다고 생각하지 않습니다. – Musa