How can I determine a file's true extension/type programmatically?

前端 未结 11 1311
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-01 17:06

I am working on a script that will process user uploads to the server, and as an added layer of security I\'d like to know:

Is there a way to detect a file\'s true e

11条回答
  •  抹茶落季
    2020-12-01 17:47

    In *nix, the first two bytes of the file tells you (see "magic number"). In Windows, ...sometimes this will be true ("header info"). It is, ultimately, O.S. dependent.

提交回复
热议问题