What is the best way to determine whether or not a file is an image in PHP?

前端 未结 12 651
有刺的猬
有刺的猬 2021-01-22 07:25

I have a sever which people can upload files to. The problem is that some of the filenames are mangled (dont have any extension) and so I cannot immediately determine file type.

12条回答
  •  忘掉有多难
    2021-01-22 07:40

    You can use getimagesize It does not require the GD image library and it returns same information about image type. http://it2.php.net/manual/en/function.getimagesize.php

提交回复
热议问题