Canman2005 Posted May 27, 2007 Share Posted May 27, 2007 Hi all I have a simple file upload script. but I want to capture and store the files mime type. What is the easiest way to do this? Any help would be great Thanks in advance Ed Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted May 27, 2007 Share Posted May 27, 2007 $_FILES['inputname']['type'] wiil give you the mime type of the uploaded file. Quote Link to comment Share on other sites More sharing options...
textbox Posted May 28, 2007 Share Posted May 28, 2007 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 '?/?'; } } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.