Skip to content

Instantly share code, notes, and snippets.

@foru17
Last active August 29, 2015 14:13
Show Gist options
  • Save foru17/3d9e3a4693444fac2444 to your computer and use it in GitHub Desktop.
Save foru17/3d9e3a4693444fac2444 to your computer and use it in GitHub Desktop.
几个进行文件操作的js方法
//判断文件类型
function checkFileType(file) {
allowedDocTypes = ["application/pdf", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"];
if (file.type.indexOf("image/") == 0) {
return "image"
} else if (allowedDocTypes.indexOf(file.type) > -1) {
return "doc"
}
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment