Welcome Guest, Not a member yet? Register   Sign In
Identifying uploaded files with mime type application/octet-stream as images
#3

[eluser]Monarobase[/eluser]
Hello,

I don't know what it's worth security or ressource wise but what about the following approach to get the mime type :

Code:
function _getmime($file){
    if($info = @getimagesize($file)) {
        return image_type_to_mime_type($info[2]);
    } else {
        return mime_content_type($file);
    }
}

This method doesn't need a specific php install and so far has returned the correct mime type on all files I have tested so far, even with the wrong file extension...


Messages In This Thread
Identifying uploaded files with mime type application/octet-stream as images - by El Forum - 05-02-2010, 03:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB