Check the MIME Type of a file created by PHPExcel

Topics: Developer Forum, User Forum
Feb 28, 2008 at 4:10 PM
Edited Feb 28, 2008 at 4:12 PM
Hi!

I would like to know what is the MIME type of a Excel document created by PHPExcel. Normally it should be: application/vnd.ms-excel for Excel2003 document or application/vnd.openxmlformats-officedocument.spreadsheetml.sheet for an Excel2007 document. But when i am checking the mime type with PHP to upload a file already created it is not working....

Below is my PHP code to check which mime type the file is (it is working fine normally):

if(($FILES$fileElementName'type'=='application/vnd.ms-excel')||($FILES$fileElementName'type'=='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')){
//action
} else {
//action2
}

Does someone has any clue about it?

Thanks a lot!
Ludo
Coordinator
Feb 28, 2008 at 5:04 PM
Is there a mime type definition in your web server's configuration present for XLSX?
Feb 29, 2008 at 9:25 AM
Edited Feb 29, 2008 at 9:26 AM

maartenba wrote:
Is there a mime type definition in your web server's configuration present for XLSX?


Thanks for your quick reply maartenba! :)

I am using one of the last version of XAMPP (http://www.apachefriends.org/en/xampp.html) as test server (because the web application is not running yet). I check a bit online, I could not find any information about it. So probably it does that... I do not know..
The thing is it recognizes well the Excel2003 files when I send one I just created, it does the action1 (which is what I want), but when I send a Excel file created with PHPExcel so with normally the MIME type of Excel2007, it does not work and it executes the action2.
Feb 29, 2008 at 10:16 AM
Hi!

Actually I just try now and it is working fine! :-) I worked a bit on it, yesterday... Maybe I correct one mistake I did without noticing...

Thanks a lot, anyway! Take care!
Keep up with the good work!
Ciao,
Ludo
Coordinator
Feb 29, 2008 at 10:44 AM
Glad it works now! Happy PHPExcel-ing :-)