Ways to stop people from uploading GIFs with injections in them?

后端 未结 7 675
无人共我
无人共我 2021-02-01 06:36

I have a PHP website where people can fill out help-tickets. It allows them to upload screenshots for their ticket. I allow gif, psd, bmp, jpg, png, tif to be uploaded. Upon

7条回答
  •  时光取名叫无心
    2021-02-01 07:24

    Late response, but may be useful for somebody. You may try such approach:

    //saves filtered $image to specified $path
    function save($image,$path,$mime) {
        switch($mime) {
            case "image/jpeg"   : return imagejpeg(imagecreatefromjpeg($image),$path);
            case "image/gif"    : return imagegif(imagecreatefromgif($image),$path);
            case "image/png"    : return imagepng(imagecreatefrompng($image),$path);
        }
        return false;
    };
    

提交回复
热议问题