相关疑难解决方法(0)

PHP上传文件增强了安全性

嘿..我的问题是如何防止有人上传病毒或某些恶意代码与您假装的扩展程序,例如我有一个pdf文件上传器,任何人都可以上传带有pdf伪装的二进制文件,有很多程序可以做到这一点.

php security upload file

15
推荐指数
3
解决办法
6317
查看次数

如何处理图像的mime类型"application/octet-stream"?

我有一个功能,可以在飞行中制作网址图片缩略图!我总是传递给jpg类型的这个函数图像,但是当我传递带有".jpg"扩展名的图像时会出现问题.但是当我尝试获取它的mime类型时,我发现它的" application/octet-stream "..在这个php页面中,这个mime类型指的是其中一个

IMAGETYPE_JPC,IMAGETYPE_JPX,IMAGETYPE_JB2

我需要修改我的函数来处理这个mime类型?

注意^^^^^^

function thumb($path,$width,$height) // $path => image url
{
        $file_dimensions = getimagesize($path);
        $file_type = image_type_to_mime_type($file_dimensions[2]);
        list($Cwidth, $Cheight) = getimagesize($path);
        if ($file_type=='image/jpeg'||$file_type=='image/pjpeg'){
            // Load
        $thumb = imagecreatetruecolor($width, $height);
        $source = imagecreatefromjpeg($path);
        // Resize
        imagecopyresized($thumb, $source, 0, 0, 0, 0, $width, $height, $Cwidth, $Cheight);
        header('Content-Type: image/jpeg');
        imagejpeg($thumb);
        }
        else if ($file_type=='application/octet-stream')
        {
           // ^^^^^ what I should write here
        }
        else
        {
            echo "Not supported type";
        } 
} 
Run Code Online (Sandbox Code Playgroud)

php thumbnails gd2 mime-types

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

php ×2

file ×1

gd2 ×1

mime-types ×1

security ×1

thumbnails ×1

upload ×1