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

后端 未结 9 1827
野性不改
野性不改 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 00:59

    Many filetypes have "magic numbers" at the beginning of the file to identify them, You can read some bytes from the front of the file and compare them to a list of known magic numbers.

提交回复
热议问题