Jump to content

getting file mime type


Canman2005

Recommended Posts

Here is one way i do it.

 

// return the mime type associated with a filename including extension.
function getMimeType( $filename ){
    
    $extension = substr( $filename , strrpos( $filename, '.' ) + 1 );

    switch( $extension ) {
        
        case( 'gif' ) : return 'image/gif';
        case( 'jpg' ) : return 'image/jpeg';
        case( 'png' ) : return 'image/png';
        case( 'txt' ) : return 'text/plain';
        case( '3gpp' ) : return 'video/3gpp';
        case( 'amr' ) : return 'audio/amr';
        default : return '?/?';
    }        
} 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.