Re: [PHP] fileinfo returning wrong mime type for Excel files
On Thu, 2009-07-30 at 21:26 -0400, b wrote: On 07/30/2009 10:15 AM, Ashley Sheridan wrote: On Thu, 2009-07-30 at 07:12 -0700, Christoph Boget wrote: You could email it to me, which I presume is better if you replied back just to me and not the list? Just copying the list back on in this one now. I don't know of any places that you could upload a file to off the top of my head. Anyone have any links? Just google upload file; there are a bunch of sites that do this to choose from. (I've never used any so I can't recommend one over the others) If it helps any with testing, on my laptop (brand new Fedora 11 install) a standard .xls file created with OOo3 is showing up as just 'test.xls: application/vnd.ms-office; charset=binary' and not a specific Excel sheet. Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fileinfo returning wrong mime type for Excel files
/usr/share/file/magic /usr/share/file/magic has lots of rules to know its type and its just matching it. I know it has a lot of rules. Grepping it for excel shows that there are rules in it for those types of files as well. Maybe your file is quite strange . have you tried with other xls files? Yes, I have; the result is the same for all. what does file /path/to/my/excel.xls say $ file excel.xls excel.xls: Microsoft Office Document Interestingly... $ file word.doc word.doc: Microsoft Office Document So apparently, to the file command, there is no distinction. That seems both odd and wrong to me. But not nearly as wrong as fileinfo reporting application/msword as the mime type of an excel document. thnx, Christoph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fileinfo returning wrong mime type for Excel files
Christoph Boget wrote: /usr/share/file/magic /usr/share/file/magic has lots of rules to know its type and its just matching it. I know it has a lot of rules. Grepping it for excel shows that there are rules in it for those types of files as well. Maybe your file is quite strange . have you tried with other xls files? Yes, I have; the result is the same for all. what does file /path/to/my/excel.xls say $ file excel.xls excel.xls: Microsoft Office Document Interestingly... $ file word.doc word.doc: Microsoft Office Document So apparently, to the file command, there is no distinction. That seems both odd and wrong to me. But not nearly as wrong as fileinfo reporting application/msword as the mime type of an excel document. thnx, Christoph Have you tried using 'file -i' from the command line: after all you are looking for a MIME type with your fileinfo... Having said that, with file -i on my system, Word documents are 'application/msword' and Excel files are 'application/octet-stream' -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fileinfo returning wrong mime type for Excel files
On 07/30/2009 08:53 AM, Peter Ford wrote: Have you tried using 'file -i' from the command line: after all you are looking for a MIME type with your fileinfo... Having said that, with file -i on my system, Word documents are 'application/msword' and Excel files are 'application/octet-stream' Fedora11 (2.6.29.6-213.fc11.i586) $ file excel.xls excel.xls: CDF V2 Document, Little Endian, Os: Windows, Version 5.1, Code page: 1252, Author: ??, Last Saved By: ELAN, Name of Creating Application: Microsoft Excel, Last Printed: Sun Nov 6 18:04:20 2005, Create Time/Date: Tue Nov 1 02:56:47 2005, Security: 0 $ file -i excel.xls excel.xls: application/vnd.ms-excel; charset=binary Using 5.2.9, the OP's script prints: application/vnd.ms-excel; charset=binary I wonder if the problem lies with the documents themselves. Last May, I posted a msg here about how FileInfo was reporting back application/msword application/msword for some (but not all) Word docs. I never received a reply about it but came up with a hack to split on the space, if present. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fileinfo returning wrong mime type for Excel files
Have you tried using 'file -i' from the command line: after all you are looking for a MIME type with your fileinfo... Having said that, with file -i on my system, Word documents are 'application/msword' and Excel files are 'application/octet-stream' $ file -i excel.xls excel.xls: application/msword The xls file I am using was generated with Excel (of Office 2007) for the Mac. So either you have a different magic file (assuming that's what the file command uses) than I do or different versions of excel contain different information. thnx, Christoph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fileinfo returning wrong mime type for Excel files
Having said that, with file -i on my system, Word documents are 'application/msword' and Excel files are 'application/octet-stream' Fedora11 (2.6.29.6-213.fc11.i586) $ file excel.xls excel.xls: CDF V2 Document, Little Endian, Os: Windows, Version 5.1, Code page: 1252, Author: ??, Last Saved By: ELAN, Name of Creating Application: Microsoft Excel, Last Printed: Sun Nov 6 18:04:20 2005, Create Time/Date: Tue Nov 1 02:56:47 2005, Security: 0 Red Hat 4.1.2-14 $ file excel.xls excel.xls: Microsoft Office Document I'm not getting all that extra information. $ file -i excel.xls excel.xls: application/vnd.ms-excel; charset=binary $file -i excel.xls excel.xls: application/msword I wonder if the problem lies with the documents themselves. Last May, I posted a msg here about how FileInfo was reporting back application/msword application/msword for some (but not all) Word docs. I never received a reply about it but came up with a hack to split on the space, if present. I saw that post and that is something we are getting occasionally as well. And it may perhaps be an issue with the documents themselves. As I stated in a post I just made, the excel document I'm looking at was created using Office 2007 for the Mac. thnx, Christoph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fileinfo returning wrong mime type for Excel files
On Thu, 2009-07-30 at 09:51 -0400, Christoph Boget wrote: Having said that, with file -i on my system, Word documents are 'application/msword' and Excel files are 'application/octet-stream' Fedora11 (2.6.29.6-213.fc11.i586) $ file excel.xls excel.xls: CDF V2 Document, Little Endian, Os: Windows, Version 5.1, Code page: 1252, Author: ??, Last Saved By: ELAN, Name of Creating Application: Microsoft Excel, Last Printed: Sun Nov 6 18:04:20 2005, Create Time/Date: Tue Nov 1 02:56:47 2005, Security: 0 Red Hat 4.1.2-14 $ file excel.xls excel.xls: Microsoft Office Document I'm not getting all that extra information. $ file -i excel.xls excel.xls: application/vnd.ms-excel; charset=binary $file -i excel.xls excel.xls: application/msword I wonder if the problem lies with the documents themselves. Last May, I posted a msg here about how FileInfo was reporting back application/msword application/msword for some (but not all) Word docs. I never received a reply about it but came up with a hack to split on the space, if present. I saw that post and that is something we are getting occasionally as well. And it may perhaps be an issue with the documents themselves. As I stated in a post I just made, the excel document I'm looking at was created using Office 2007 for the Mac. thnx, Christoph To test that, is there any way you could put a blank spreadsheet document created from that same computer online somewhere so that people on the list can check to see if it is the file that is being bad and not your mime types file? Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fileinfo returning wrong mime type for Excel files
The xls file I am using was generated with Excel (of Office 2007) for the Mac. So either you have a different magic file (assuming that's what the file command uses) than I do or different versions of excel contain different information. I just tried using an excel spreadsheet saved using Office 2003 on XP and received the same output: application/msword. thnx, Christoph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] fileinfo returning wrong mime type for Excel files
From: Christoph Boget Have you tried using 'file -i' from the command line: after all you are looking for a MIME type with your fileinfo... Having said that, with file -i on my system, Word documents are 'application/msword' and Excel files are 'application/octet-stream' $ file -i excel.xls excel.xls: application/msword The xls file I am using was generated with Excel (of Office 2007) for the Mac. So either you have a different magic file (assuming that's what the file command uses) than I do or different versions of excel contain different information. Those two statements are not mutually exclusive. Both may be true. Bob McConnell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fileinfo returning wrong mime type for Excel files
On Thu, 2009-07-30 at 07:12 -0700, Christoph Boget wrote: Well, I didn't want to upload a file to the list. Putting it in a central location where those interested parties could access it would be a much better option. thnx, Chris __ From: Ashley Sheridan a...@ashleysheridan.co.uk To: Christoph Boget jcbo...@yahoo.com Sent: Thursday, July 30, 2009 10:05:33 AM Subject: Re: [PHP] fileinfo returning wrong mime type for Excel files On Thu, 2009-07-30 at 07:04 -0700, Christoph Boget wrote: To test that, is there any way you could put a blank spreadsheet document created from that same computer online somewhere so that people on the list can check to see if it is the file that is being bad and not your mime types file? Sure. Do you know of a place I can put it? What I'm working on is an intranet. thnx, Christoph You could email it to me, which I presume is better if you replied back just to me and not the list? Thanks, Ash http://www.ashleysheridan.co.uk Just copying the list back on in this one now. I don't know of any places that you could upload a file to off the top of my head. Anyone have any links? Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fileinfo returning wrong mime type for Excel files
On 07/30/2009 10:15 AM, Ashley Sheridan wrote: On Thu, 2009-07-30 at 07:12 -0700, Christoph Boget wrote: You could email it to me, which I presume is better if you replied back just to me and not the list? Just copying the list back on in this one now. I don't know of any places that you could upload a file to off the top of my head. Anyone have any links? Just google upload file; there are a bunch of sites that do this to choose from. (I've never used any so I can't recommend one over the others) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] fileinfo returning wrong mime type for Excel files
Consider the following: $finfo = finfo_open( FILEINFO_MIME, '/usr/share/file/magic' ); if( $finfo ) { $mimeType = finfo_file( $finfo, '/path/to/my/excel.xls' ); finfo_close($finfo); } echo $mimeType; When I run the above, it echoes out application/msword. Why? I understand that both excel and word are part of the office suite but why isn't it returning application/excel as it should? As far as I can tell, we're using the most up to date version of fileinfo for PHP 5.2.5. Is there something else I'm missing? Or doing wrong? thnx, Christoph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] fileinfo returning wrong mime type for Excel files
On Wed, Jul 29, 2009 at 05:15:38PM -0400, Christoph Boget wrote: Consider the following: $finfo = finfo_open( FILEINFO_MIME, '/usr/share/file/magic' ); if( $finfo ) { $mimeType = finfo_file( $finfo, '/path/to/my/excel.xls' ); finfo_close($finfo); } echo $mimeType; When I run the above, it echoes out application/msword. Why? I understand that both excel and word are part of the office suite but why isn't it returning application/excel as it should? As far as I can tell, we're using the most up to date version of fileinfo for PHP 5.2.5. Is there something else I'm missing? Or doing wrong? thnx, Christoph Presumably, this information comes directly from /usr/share/file/magic. FWIW, my copy of this file is in /usr/share/misc/file/magic, which is where the man page says it should be. Debian Linux v5. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php