I use $ext = $uploadedFile->guessExtension() == null ? $uploadedFile- >getExtension() : $uploadedFile->guessExtension(); where uploadedFile is a field of my entity (not persisted) used in the forms. I followed the cookbook:
http://symfony.com/doc/current/cookbook/doctrine/file_uploads.html and sorry....but I just (by mistake) mark your message as spam....and there is no way to undo this!!!! DOH! :D On 17 Giu, 16:44, Gustavo Adrian <comfortablynum...@gmail.com> wrote: > Thanks for the tip! Yes, this topic is a real headache. I had this type of > issue on centos too (although I don't remember with which filetypes). For > now I'm handling this problem in the insecure way.. using the mime and > extension sent by the browser, and marking the file as "insecure" in that > case. It's the only way I can make it work. None of the three mime type > guessers works. I have problems with several file types, including the one > you mention. > > BTW, after updating yesterday Symfony 2 I saw that File classes that handle > the uploaded files have changed. I was using "UploadedFile::getExtension" to > get the extension, but now it returns an empty string. It uses pathinfo to > get the extension. I didn't have a deep look at it so I'm not sure why this > happens. I mention it only if it's relevant to someone. In my case I'm just > getting the extension from the original name for now (because the > "guessExtension" obviusly is not working if the mime type is wrong. For a > .docx it's giving me a '.zip' extension). > > I'd like to keep this message alive in case anyone has more comments like > yours about this which are helpful in this topic. > > Thanks! > > 2011/6/17 matteosister <matt...@gmail.com> > > > > > > > > > yes same problem here. > > I'm on ubuntu too. > > I' think it's a problem bound to proprietary file types. > > Take a look at /etc/mime.types for mime supported by your system. > > > For me the problem comes with .doc documents. It says that it is a > > application/vnd.ms-office instead of ms-word > > > This is why microsoft sucks. > > > On 17 Giu, 15:22, Gustavo Adrian <comfortablynum...@gmail.com> wrote: > > > Is someone having this issue? > > > > 2011/6/16 Gustavo Adrian <comfortablynum...@gmail.com> > > > > > Hi all, > > > > > I wanted to ask you guys if you've found a "definitive" way to handle > > mime > > > > type detection issues. I recently implemented file upload handling in > > my app > > > > with Symfony 2 and I'm having problems detecting, for example, .docx > > files. > > > > When I upload a .docx, it detects a mime type of "application/zip". I > > have > > > > this issue with other file types too (like .csv). > > > > > I know this is not a Symfony 2 specific problem, I had this problem > > before, > > > > but I'd like to know what do you think about this. I'm using right now: > > > > > Apache 2.2.16 > > > > PHP 5.3.3 > > > > Ubuntu 11 > > > > > and I have FileInfo v1.0.5-dev > > > > > How do you handle this situations? > > > > > Thanks. > > > -- > > If you want to report a vulnerability issue on symfony, please send it to > > security at symfony-project.com > > > You received this message because you are subscribed to the Google > > Groups "symfony users" group. > > To post to this group, send email to symfony-users@googlegroups.com > > To unsubscribe from this group, send email to > > symfony-users+unsubscr...@googlegroups.com > > For more options, visit this group at > >http://groups.google.com/group/symfony-users?hl=en -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en