From: Greg T. <gr...@ta...> - 2005-07-26 17:25:08
|
On Tue, 2005-07-26 at 11:18 -0400, Verdon Vaillancourt wrote: > In a module of mine, I have a case where I need to check the mimetype=20 > of a file already on the server. In my initial attempt, I used... >=20 > $type =3D mime_content_type($file); >=20 > Then I discovered that mime_content_type may not be available in all=20 > php builds, and/or that it may not be enabled in php.ini. ... > However, I suspect this will not work on a windows server. >=20 > That leaves me with a couple options... >=20 > 1) go with the above solution which I think will work for most people,=20 > and provide documentation for the rest > 2) use function_exists('mime_content_type') and if it doesn't exist,=20 > don't even offer the module feature to the end user > 3) use function_exists('mime_content_type') and if it doesn't exist,=20 > use a file ext check instead and map to mimetype (not very good I know) I don't recommend option #1 at all. It is usually problematic and more trouble than it's worth (e.g., it tends to generate support issues needlessly, even when documented). #2 would probably be my preference if a notification was included when the functionality was disabled. #3 might be nice as well except you still have the problems from earlier, such as: - Windows servers won't work with the "workaround" as you pointed out. - Some Linux and Unix systems don't provide the "file" command either. It would break there as well. - It's somewhat "hackish" and requires quite a bit of workaround for you to implement properly. Therefore, I wouldn't do #3 unless you REALLY NEEDED this functionality at all costs. Option #2 removes some ambiguity but still provides a clean implementation of the built-in PHP functionality. > What I wonder if, is there is something in the phpws api that will do a=20 > similar job for me, that I am not aware of? Keep in mind, I'm dealing=20 > with a file already on the server, not one being uploaded. I don't know enough about the "deep parts" of the api to answer this one. I'll let the experts handle it. :-) Good luck! Greg |