Fork me on GitHub

ajaxFileUpload js判断类型

function ajaxFileUpload() {
    var File_box = document.getElementById('V_file');
    var extend = File_box.value.substring(File_box.value.lastIndexOf(".") + 1);
    if (File_box.value == "" || File_box.value == null) {
        alert('请先选择文件!');
    }
    else if (!(extend.toLowerCase() == "flv" || extend.toLowerCase() == "f4v" || extend.toLowerCase() == "mp4"))
    {
        alert("播放器只支持flv,f4v,mp4格式文件,请重新上传。");
    }
    else {
        $.ajaxFileUpload({
            url: 'Video_Manage_Api.ashx?act=file',
            secureuri: false,
            fileElementId: 'V_file',
            dataType: 'json',
            success: function (data, status) {
                FileSrc = '../Upload/Video/' + data[0];
                alert(data[0] + '上传成功');
                $("#FileUploadDiv").css("display", "none");
                $("#FileLabel").css("display", "block");
            }
        });
    }
}

posted @ 2014-04-21 16:43  乔闻  阅读(650)  评论(0编辑  收藏  举报