Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php	(revision 39820)
+++ wp-includes/functions.php	(working copy)
@@ -2366,7 +2366,13 @@
 	 */
 	try {
 		if ( is_callable( 'exif_imagetype' ) ) {
-			$mime = image_type_to_mime_type( exif_imagetype( $file ) );
+			$imagetype = exif_imagetype( $file );
+			// avoid falling back to application/octet-stream when exif_imagetype returns false
+			if( $imagetype !== false ) {
+				$mime = image_type_to_mime_type( $imagetype ); 
+			} else {
+				$mime = false;
+			}
 		} elseif ( function_exists( 'getimagesize' ) ) {
 			$imagesize = getimagesize( $file );
 			$mime = ( isset( $imagesize['mime'] ) ) ? $imagesize['mime'] : false;
@@ -2373,6 +2379,14 @@
 		} else {
 			$mime = false;
 		}
+		 if( $mime === false && function_exists ( 'finfo_file' ) ){ 
+			/* if the mime type is false we might have an 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;
 	}
