![]() |
File Upload type and mimes (a solution + office 2007 mime code/icons) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: File Upload type and mimes (a solution + office 2007 mime code/icons) (/showthread.php?tid=14710) |
File Upload type and mimes (a solution + office 2007 mime code/icons) - El Forum - 01-12-2009 [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/Office+2007+File+Icons+For+Windows+SharePoint+Services+20+And+SharePoint+Portal+Server+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', (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. File Upload type and mimes (a solution + office 2007 mime code/icons) - El Forum - 01-13-2009 [eluser]xwero[/eluser] Thanks for the contribution, but are all browsers identifying the mimes like that? File Upload type and mimes (a solution + office 2007 mime code/icons) - El Forum - 01-13-2009 [eluser]echadwickb[/eluser] good question. I don't know honestly. From reading these forums, it appears that there is some discrepancy between how browsers report mime types to the server. I can at least vouch for firefox 3 and IE7 working with these types in our environment. I'm going to have to update this app eventually. If I ever get around to it, I'll try to put in the legwork to find out. File Upload type and mimes (a solution + office 2007 mime code/icons) - El Forum - 01-20-2009 [eluser]mkhairul[/eluser] I also tried to upload an office document (excel) with the extension xlsx. It kept telling me the filetype is not allowed. I look at the upload value and the filetype is \"application/octet-stream\" instead of just application/octet-stream. I have no idea why this is happening but I just added the string inside the mimetype. Code: 'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/octet-stream', '\"application/octet-stream\"'), Now it works. Anyone have any idea why this is happening? File Upload type and mimes (a solution + office 2007 mime code/icons) - El Forum - 01-20-2009 [eluser]echadwickb[/eluser] this issue has been covered in forums before. I ran into it when I was researching my problem. I believe it has to do with how certain browsers (possibly firefox?) report mime types. It's a little over my head. If I can find a link to one of those threads, I'll post it here. File Upload type and mimes (a solution + office 2007 mime code/icons) - El Forum - 01-02-2010 [eluser]heenji[/eluser] i have the same problem when i want to upload a xml file,it failed!. then i just check the $_FILES,find the file_type is application/octet-stream,then modify the mime.php in config,modify Code: 'xml' => 'text/xml', Code: 'xml' => array('text/xml','application/xml','application/octet-stream'), File Upload type and mimes (a solution + office 2007 mime code/icons) - El Forum - 01-10-2010 [eluser]Zeeshan Rasool[/eluser] Same issue is with my code, i couldn't upload the office 2007 file please give any solution Thanks A lot ! File Upload type and mimes (a solution + office 2007 mime code/icons) - El Forum - 07-07-2010 [eluser]zwadder[/eluser] I tried the above solution but it didn't work, did some digging in the CI_Upload class and did found out that not all types were loaded, did change the order of the allowed types and this did the trick. |