DOCX files detected as x-zip

See all posts Reply

DOCX files detected as x-zip new!
by Robin, 14 years, 8 months ago
Hello everyone,

I've been playing around with the upload class for a bit now and things seems to work pretty well. I added the application/msword MIME-type to the allowed list, but as soon as I try to upload a .docx file, it throws an error saying "Incorrect type of file".

This is the error log it produces:
- class version : 0.29
- operating system : Linux
- PHP version : 5.2.8
- GD version : 2.0.34
- supported image types : png jpg gif bmp
- open_basedir : /home/website:/opt/php4/lib/php:/opt/php5/lib/php:/nfs/sessions:/tmp
- language : en_GB
source is an uploaded file
- upload OK
- file name OK
determining MIME type
- Checking MIME type with Fileinfo PECL extension
Fileinfo PECL extension not available
- Checking MIME type with UNIX file() command
MIME type detected as application/x-zip by UNIX file() command
- MIME validated as application/x-zip
source variables
- You can use all these before calling process()
file_src_name : oink.docx
file_src_name_body : oink
file_src_name_ext : docx
file_src_pathname : /tmp/phpOoHGPf
file_src_mime : application/x-zip
file_src_size : 10078 (max= 16777216)
file_src_error : 0
process file and return the content
- file size OK
- error: Incorrect type of file.


What should I do to fix this problem?Reply
Re: DOCX files detected as x-zip new!
by colin, 14 years, 8 months ago
I am afraid it is "normal". The DOCX files are indeed ZIP files.

You may want to update your system, so that the MIME detection librairies can detect the new Office formats. For instance, libmagic was discussing it a while back, and again recently. I looked in the latest version of the file command, but it doesn't seem to be able to deal with the new MS Office formats.Reply