How do I tell if someone's faking a filetype? (PHP)

后端 未结 9 1830
野性不改
野性不改 2021-02-08 00:31

I\'m programming something that allows users to store documents and pictures on a webserver, to be stored and retrieved later. When users upload files to my server, PHP tells m

相关标签:
9条回答
  • 2021-02-08 01:19

    On a unix system, capturing the output from the 'file' command should provide adequate info.

    0 讨论(0)
  • 2021-02-08 01:19

    Magic number. If you can read first few bytes of a binary file you can know what kind of file it is.

    0 讨论(0)
  • 2021-02-08 01:20

    Check out the FileInfo PECL extension for PHP, which can do the MIME magic lookups for you.

    0 讨论(0)
提交回复
热议问题