Darren Black
2012-12-10 22:54:35 UTC
G'day
I'm having a problem when uploading .docx files to a symfony application
running on apache. When a .docx file is uploaded, the mime type is being
guessed as an 'application/zip'. I found an old posting<https://groups.google.com/forum/?fromgroups=#!topic/symfony-users/9oI0aCNflpU>which mentions this same issue, but the workaround seems to rely on
validating the file in the controller. I have tried adding the docx mime
type to apache, as per this post<http://serverfault.com/questions/19060/why-are-docx-xlsx-pptx-downloading-from-webserver-as-zip-files>,
but it made no difference (the web server will happily hand out docx files
with the right mime type regardless).
I'd like validate the file upload using the assert annotation (instead of
manually validating the file in the controller) - here's the property from
my class:
/**
* @Assert\NotBlank
* @Assert\File(
* maxSize="10M",
* maxSizeMessage="Document is too large - maximum size is 10MB",
* mimeTypes = {"application/pdf", "application/msword",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"},
* mimeTypesMessage = "Please upload an MS Word doc, or a PDF"
* )
*/
protected $file;
The validation works great for pdf's and .doc files, but obviously chokes
on docx, because it believes the mime-type is application/zip
So, my question is, how would i go about doing this? I've found the api on
MimeTypeGuesser<http://api.symfony.com/2.0/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.html> but
i'm not sure if this is the right way to go? I would have thought that this
might be a fairly common issue (do a lot of organisations still use MS
Word?), and perhaps it's something I've missed, or maybe to do with my
hosting/apache config?
Thanks!
Darren
--
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 "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en
I'm having a problem when uploading .docx files to a symfony application
running on apache. When a .docx file is uploaded, the mime type is being
guessed as an 'application/zip'. I found an old posting<https://groups.google.com/forum/?fromgroups=#!topic/symfony-users/9oI0aCNflpU>which mentions this same issue, but the workaround seems to rely on
validating the file in the controller. I have tried adding the docx mime
type to apache, as per this post<http://serverfault.com/questions/19060/why-are-docx-xlsx-pptx-downloading-from-webserver-as-zip-files>,
but it made no difference (the web server will happily hand out docx files
with the right mime type regardless).
I'd like validate the file upload using the assert annotation (instead of
manually validating the file in the controller) - here's the property from
my class:
/**
* @Assert\NotBlank
* @Assert\File(
* maxSize="10M",
* maxSizeMessage="Document is too large - maximum size is 10MB",
* mimeTypes = {"application/pdf", "application/msword",
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"},
* mimeTypesMessage = "Please upload an MS Word doc, or a PDF"
* )
*/
protected $file;
The validation works great for pdf's and .doc files, but obviously chokes
on docx, because it believes the mime-type is application/zip
So, my question is, how would i go about doing this? I've found the api on
MimeTypeGuesser<http://api.symfony.com/2.0/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.html> but
i'm not sure if this is the right way to go? I would have thought that this
might be a fairly common issue (do a lot of organisations still use MS
Word?), and perhaps it's something I've missed, or maybe to do with my
hosting/apache config?
Thanks!
Darren
--
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 "Symfony2" group.
To post to this group, send email to symfony2-/***@public.gmane.org
To unsubscribe from this group, send email to
symfony2+unsubscribe-/***@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/symfony2?hl=en