files-bytes
v1.1.5
Published
File authenticity type check
Downloads
22
Maintainers
Readme
file-bytes
- Obtain the true type of file
install
npm i file-bytes
yarn add file-bytes
pnpm install file-bytes
Introduction and use, using Vue as an example
<template>
<input type="file" @change="handelFiles" />
</template>
<script lang="ts" setup>
import { checkFileType } from "/npm/file-bytes";
function handelFiles(file: any) {
const { files } = file.target;
checkFileType(files[0]).then((res: string) => {
/**
* If the second parameter is not passed, the true type of the file will be returned. If false is returned,
* it indicates that the file type has not been added to the library and will continue to be added later
*/
console.log(res);//'.png'|'.js'|'.mp4'|......
});
checkFileType(files[0],".png").then((res: string) => {
/**
* If the second parameter is passed, it indicates that you predicted the file type you selected.
* If the actual file type does not match the predicted type,
* it will return true. Otherwise, it will return false
*/
console.log(res);//true | false
});
}
</script>
Due to the large number of file types, apart from common file types, if you are unable to verify your files, it indicates that the tool has not been included, and you may need to contact the developer for assistance
Contact me
email:[email protected] | qq:1920872385
more
Git See alsogithub。