| 607 | |
| 608 | // Get the mime type |
| 609 | $mime_type = ''; |
| 610 | if ( extension_loaded('fileinfo') ) { |
| 611 | $finfo = new finfo(); |
| 612 | $mime_type = $finfo->file( $file_array['tmp_name'], FILEINFO_MIME ); |
| 613 | } elseif ( function_exists('mime_content_type') ) { |
| 614 | $mime_type = mime_content_type( $file_array['tmp_name'] ); |
| 615 | } |
| 616 | if ( !empty( $mime_type) ) { |
| 617 | $types = explode('/', $mime_type, 2); |
| 618 | if ( 'image' !== $types[0] ) { |
| 619 | // This is not an image |
| 620 | @unlink($file_array['tmp_name']); |
| 621 | $file_array['tmp_name'] = ''; |
| 622 | } |
| 623 | } |