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/vnd.ms-office"
So I added this line to the $defaultExtensions array in MimeTypeExtensionGuess.php :
'application/vnd.ms-office' => '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.
$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: http://php.net/manual/en/function.pathinfo.php
- Symfony2 - Why use XML for settings/config?
- Symfony2 UploadedFile::guessExtension() for XML
- Why most symfony2 thirdpary bundles use xml some yml and very few annotations for configuration?
- How is the notation for constants with bitwise operator in symfony2 xml configuration
- Symfony2 - Validation not working for embedded Form Type
- Allow trailing slash for Symfony2 route without params?
- How do you retrieve current date for Symfony2
- Symfony2 redirect for event listener?
- There is no extension able to load the configuration for "facebookbundle" symfony2
- How to properly set up Varnish for Symfony2 sites?
- Query with EXISTS for Doctrine Symfony2
- Symfony2 - Set translation domain for a whole form
- Authentication for a Symfony2 api (for mobile app use)
- Best Practices for developing a multi-tenant application with Symfony2 and Doctrine2
- Symfony2 - How to put label and input for checkboxes/radios in a same line?
- Setting up GIT for Symfony2 project: why add web/bundles folder to gitignore
- symfony2 use multiple url pattern for a single Controller Action using regular expression
- How to use the AccessDecisionManager in Symfony2 for authorization of arbitrary users?
- Set max_execution_time for specific controller in symfony2
- Configure output dir for Assetic in Symfony2
- How do I check for user role in symfony2 for urls not falling under patterns defined security.yml?
- Symfony2 create own encoder for storing password
- What are the main differences between the PSR-2 coding standard and the Symfony2 code standard for phpcs?
- Symfony2 FOSElasticaBundle update index for all entities related to the entity updated
- SQLSTATE  Access denied for user 'root'@'localhost' (using password: YES) Symfony2
- How to correctly invalidate cache on production for Symfony2 application?
- Symfony2 : customize error pages for different bundles
- Display all errors with form_errors(form) plus for each field in symfony2
- Symfony2 / Twig : Generate Alternate Absolute URL Path for use with CDN?
More Query from same tag
- How to make a Doctrine subquery?
- Sylius : Fresh install but API does not work
- How to forward request to route name
- Controllers managed by the dependency injection container and "action" suffix
- Why composer install timeouts after 300 seconds?
- How to call cache:clear command with argumemt within another command - Symfony3
- Check if a entity already exists in the database using Symfony and Doctrine
- Symfony2 Formbuilder select
- Doctriine Query VS QueryBuilder Symfony 2.0
- How to scan a complete Symfony project for dependencies?
- Getting values of a POST multi-dimensional array with doctrine
- AngularJS with Symfony and Twig resource not found before page is fully loaded
- FOSUserBundle how to add more user roles?
- Weird issue, translations works if logged in, if not then didn't work in Symfony 2.5.6
- Symfony2 not picking up multiple routing yml files / Import not working in yml file
- Symfony form - reorder / sort CollectionType elements
- coresphere /console-bundle not found in appkernel.php in line 33
- How to override DependencyInjection part of bundle?
- Doctrine Query Join sub Query Syntax
- Search DB only working in php dev environment
- Symfony2: How to filter the options of an entity-choice form field by a certain attribute?
- Passing options to UglifyJS2 when using Assetic Bundle
- Private images in Symfony2
- Export data into CSV file in Symfony
- Symfony 2 Util SecureRandom and "null" character: how to manage it
- spawn /usr/bin/php ENOENT error on vs code
- How to convert htaccess rules to web.config for IIS7/Symfony?
- How to stop jQuery loading twice?
- Doctrine migration created by SymfonyMakerBundle tries to remove existing indexes
- access denied 403 symfony2