$(".aFileBtn").on("change","input[type='file']",function(){
var filePath=$(this).val();
//filePath.indexOf("jpg")!=-1 || filePath.indexOf("png")!=-1
if(filePath.length > 0){
$(".fileerrorTip").html("").hide();
var arr=filePath.split('\\');
var fileName=arr[arr.length-1];
$(".showFileName").html(fileName);
}else{
$(".showFileName").html("");
$(".fileerrorTip").html("您未上傳文件,或者您上傳文件類型有誤!").show();
return false
}
})
<a class="selfConBtn aFileBtn">選擇文件<input type="file" /></a>
<span class="fileerrorTip"></span>
<span class="showFileName"></span>
<a href="#" class="selfConBtn">點擊上傳</a>