拿到input file上传文件名字 显示到页面中


$(".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> 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM