I've working working hard with my team to find a solution to this problem.

It seems like Symfony's library is missing a mimeType in it's core files.

You can add the mime type in:


In my case guessExtension() couldn't recognize .xls files.

It was missing the mime type: "application/"

So I added this line to the $defaultExtensions array in MimeTypeExtensionGuess.php :

'application/' => 'xls',

In your case it might be missing:

'application/xml' => 'xml',

Cheers! I hope this helps.


Don't edit the file directly in the vendor dir (do a pull request if need be) as when upgrading you'll lose your changes.

But use $file->getClientOriginalName() to get the original file name that you have uploaded if $file->guessExtension() gets you the wrong one.

I had similar problem with mp3's being recognised as mpga's


Try to get it from the uploaded $file->getFilename() Then you can extract the extension using:

 $fileExtension = pathinfo( $file->getFilename(), PATHINFO_EXTENSION);

In the php docs:

Related Query

More Query from same tag