How to find the extension of an image from path in PHP?

前端 未结 9 781
抹茶落季
抹茶落季 2021-01-04 12:52

Is there any standard function in PHP to find only extension of an image from the corresponding file path?

For example ff my image path is like \'/testdir/dir2/image

9条回答
  •  旧时难觅i
    2021-01-04 13:19

    I would recommend you to run any uploaded/linked image(s) through a GD/ImageMagick check and re-save it to prevent any malicious codes hidden within the images. This would also allow you to save all of the images with the same extension to make things easier for you.

    http://www.php.net/imagepng
    http://www.php.net/imagegif
    http://www.php.net/imagejpeg

提交回复
热议问题