Welcome Guest, Not a member yet? Register   Sign In
File Upload type and mimes (a solution + office 2007 mime code/icons)
#1

[eluser]echadwickb[/eluser]
I spent hours the last few days troubleshooting a really annoying file upload problem. Had a user email me asking why her powerpoint 2007 file wouldn't upload to the doc management program I wrote.

Easy fix, right? Wrong! First step was to add the 5 billion Office 2007 file extensions to my controller method:

docx|docm|dotx|dotm|xlsx|xlsm|xltx|xltm|xlsb|xlam|pptx|pptm|potx|potm|ppam|ppsx|ppsm

(your welcome)

I then grabbed all the office 2007 document icons in gif format:

http://www.therightstuff.de/2006/12/16/O...+2003.aspx

(your welcome again)

Still wasn't working for her. She kept getting the file type not allowed message. I suddenly remembered the config/mimes.php. I added the mimes to the file . . .

Code:
$mimes = array( 'docm'     =>     'application/vnd.ms-word.document.macroenabled.12',
                'docx'     =>     'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
                'dotm'     =>     'application/vnd.ms-word.template.macroenabled.12',
                'dotx'     =>     'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
                'potm'     =>     'application/vnd.ms-powerpoint.template.macroenabled.12',
                'potx'     =>     'application/vnd.openxmlformats-officedocument.presentationml.template',
                'ppam'     =>     'application/vnd.ms-powerpoint.addin.macroenabled.12',
                'ppsm'     =>     'application/vnd.ms-powerpoint.slideshow.macroenabled.12',
                'ppsx'     =>     'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
                'pptm'     =>     'application/vnd.ms-powerpoint.presentation.macroenabled.12',
                'pptx'     =>     'application/vnd.openxmlformats-officedocument.presentationml.presentation',
                'xlam'     =>     'application/vnd.ms-excel.addin.macroenabled.12',
                'xlsb'     =>     'application/vnd.ms-excel.sheet.binary.macroenabled.12',
                'xlsm'     =>     'application/vnd.ms-excel.sheet.macroenabled.12',
                'xlsx'     =>     'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
                'xltm'     =>     'application/vnd.ms-excel.template.macroenabled.12',
                'xltx'     =>     'application/vnd.openxmlformats-officedocument.spreadsheetml.template'
);

(aren't I a giving person :p)

Still no dice. After hours of testing and searching these forums, I finally gave in and looked at the file_upload class (1.6.1). Turns out the class runs the uploaded file's mime type through strtolower. The mimes I copied into my mimes.php file had capital letters. I did a text replace, and it worked (the code above has already been text replaced).

Just thought I would share this with everyone else. It's not the first time that case sensitivity bit me on the a** . . . probably won't be the last either.


Messages In This Thread
File Upload type and mimes (a solution + office 2007 mime code/icons) - by El Forum - 01-12-2009, 04:47 PM



Theme © iAndrew 2016 - Forum software by © MyBB