How can JS or JQ get the type of uploaded file?

how to be on the front end

clipboard.png

clipboard.png

if it is image, you can get the type of file, but if it is a compressed file of zip or rar class, you can"t get type
. How should I get it?


the test should be available:

https://jsfiddle.net/jaylin00.


the function of this browser is very limited, so judge directly by intercepting the file name

however, it is impossible to judge if you manually change the suffix name of a file. For example, if a txt text is changed to jpg , you will not recognize

.

General binary files, to really determine the file type, are all through the "file header".
in your case, the browser supports header judgment of jpg and zip types, but he doesn't add rar header judgment, so he can't get type.
if the requirement is not high, you can set everything that can not get the type to "binary: application/octet-stream". If you want to be accurate, you have to read the file header and determine the file type yourself. The file type corresponding to the
file header can be found on the Internet.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c204fe-3283c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c204fe-3283c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?