Skip to content

Instantly share code, notes, and snippets.

@fengt
Created November 21, 2017 03:23
Show Gist options
  • Select an option

  • Save fengt/ea3dd238f248751c910e82a74ad39f8a to your computer and use it in GitHub Desktop.

Select an option

Save fengt/ea3dd238f248751c910e82a74ad39f8a to your computer and use it in GitHub Desktop.

Revisions

  1. fengt created this gist Nov 21, 2017.
    17 changes: 17 additions & 0 deletions file_extension_verification.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    $('#upload_btn').on('click', function() {
    var uploadFile = $('#upload_categories').val();
    if (!uploadFile) {
    alertify.log('请先选择文件!', 'error', 0);
    return;
    }

    var fileName = uploadFile.substr(uploadFile.lastIndexOf('\\')+1);
    var ary = ['xls', 'xlsx'];
    var suffix = uploadFile.split('.').pop().toLowerCase();
    if ($.inArray(suffix, ary) == -1) {
    alertify.log('文件类型有误,请上传excel文件!', 'error', 0);
    return;
    }

    $('#upload_category_form').submit();
    });