Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php	(revision 39820)
+++ wp-includes/functions.php	(working copy)
@@ -2366,7 +2366,11 @@
 	 */
 	try {
 		if ( is_callable( 'exif_imagetype' ) ) {
-			$mime = image_type_to_mime_type( exif_imagetype( $file ) );
+			$mime = exif_imagetype( $file );
+			// avoid falling back to application/octet-stream when exif_imagetype returns false
+			if( $mime !== false ) {
+				$mime = image_type_to_mime_type( $mime ); 
+			}
 		} elseif ( function_exists( 'getimagesize' ) ) {
 			$imagesize = getimagesize( $file );
 			$mime = ( isset( $imagesize['mime'] ) ) ? $imagesize['mime'] : false;
@@ -2373,6 +2377,14 @@
 		} else {
 			$mime = false;
 		}
+		 if( $mime === false && function_exists ( 'finfo_file' ) ){ 
+			/* if the mime type is false image file not supported by PHP Constants (this applies at least to 
+			 * svg, but  might apply to other file types) To fix this, use finfo to determine the mimetype instead 
+			 */ 
+			$finfo = finfo_open( FILEINFO_MIME_TYPE ); 
+			$mime = finfo_file( $finfo, $file ); 
+			finfo_close( $finfo ); 
+		} 
 	} catch ( Exception $e ) {
 		$mime = false;
 	}
