개발
[jQuery] file폼 확장자 체크하기.
세모리a
2013. 7. 29. 22:10
if( $("#file").val() != "" ){
var ext = $('#file').val().split('.').pop().toLowerCase();
if($.inArray(ext, ['gif','png','jpg','jpeg']) == -1) {
alert('gif,png,jpg,jpeg 파일만 업로드 할수 있습니다.');
return;
}
}
#file은 파일 id
출처 : http://stackoverflow.com/questions/651700/how-to-have-jquery-restrict-file-types-on-upload