📜  检查上传 img 扩展 jquery - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:38.995000             🧑  作者: Mango

代码示例1


function validate(file) {
    var ext = file.split(".");
    ext = ext[ext.length-1].toLowerCase();      
    var arrayExtensions = ["jpg" , "jpeg", "png", "bmp", "gif"];

    if (arrayExtensions.lastIndexOf(ext) == -1) {
        alert("Wrong extension type.");
        $("#image").val("");
    }
}