var file = $("#filedata").val(); var pos = file.lastIndexOf("\\"); var filename = file.substring(pos+1); var fileextname = filename.substring(filename.lastIndexOf("."), filename.length); 以上方法就是js获取filedata的文件名和文件名后缀,这样就可以限制上…
var a=document.querySelector('input[type=file]'); a.onchange = function (e) { //var reader = new FileReader();//reader.readAsDataURL(a.files[0]);//reader.onload = function (event) {//img.src = event.target.result;//}; var reader = new FileReader(); r…