Uploaded docx files turning into zip?

It seems to be a bug in Symfony's file type detection. A workaround is described.

The problem is Content-Sniffing. The new Office formats ARE . Zip files, and if on upload, the content is sniffed, the browser will identify this as a ZIP file and set the Content-Type header as such.

Similarly, on download unless your server sets the proper Content-Type HTTP response header, the browser will assume that this is a ZIP file.

Yes, the new Office 2007 formats are XML files that have been zipped. – TravisO Jan 20 '10 at 21:16.

Symfony 1.3+ has an option mime_type_guessers for sfValidatorFile which allows you to define your own mime type guesser PHP callable or use a build in guesser. Calling any of the 3 built-in mime type guessers finds the correct file type for docx and keeps the the docx file extension. Here is the updated code using guessFromFileinfo: $this->validatorSchema'file_name' = new sfValidatorFile(array( 'required' => true, 'path' => sfConfig::get('sf_upload_dir').

DIRECTORY_SEPARATOR. SfConfig::get('app_dir_file_sharing'). DIRECTORY_SEPARATOR, 'mime_type_guessers' => array('guessFromFileinfo'), 'mime_types' => array('application/msword', 'application/vnd.Ms-word', 'application/msword', 'application/msword; charset=binary') ), array( 'invalid' => 'Invalid file.

', 'required' => 'Select a file to upload. ', 'mime_types' => 'The file must be a supported type.' )).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions