Created
November 21, 2017 03:23
-
-
Save fengt/ea3dd238f248751c910e82a74ad39f8a to your computer and use it in GitHub Desktop.
Upload file extension verification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#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(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment