473,503 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mime_content_type() for PNG image returns "text/plain"

PHP 4.3.8 with UNIX with option --with-magic_mime

[PHP] echo mime_content_type('/images/myimage.png'); // RETURNS
"text/plain"[/PHP]

PHP 4.3.11 with UNIX with option --with-magic_mime

[PHP] echo mime_content_type('/images/myimgae.png'); // RETURNS
"text/plain"[/PHP]

PHP 4.3.2 and 4.3.6 with UNIX, PHP 5.0.4 with Windows (w/o magic_mime
support)

[PHP] echo mime_content_type('/images/myimage.png'); // RETURNS
"image/png"[/PHP]

I am having to shut off support within a portable web application that
will be housed, at least, in the following environments:

1. PHP 4.3.2/UNIX
2. PHP 4.1.2/UNIX
3. PHP 4.3.6/UNIX
4. PHP 4.3.11/UNIX
5. PHP 5.0.4/Windows

this means that the environment must be universal for this to work, and
in the case of a few test environments that were running 4.3.11 -
5.0.4, mime_content_type() under PHP supporting --with-magic_mime would
always return
text/plain
and not
image/png
I think this is a bug but cannot independently verify this unless
someone else here duplicates my test, provided they too are running PHP
4.3.8+ with --with-magic_mime support enabled and see if they get the
same results. Otherwise, how do I work around this problem? [Note: I
wrote my own "mime_content_type()" function that works just fine)

Thanx
Phil

Aug 11 '05 #1
3 5259
comp.lang.php wrote:
PHP 4.3.8 with UNIX with option --with-magic_mime

[PHP] echo mime_content_type('/images/myimage.png'); // RETURNS
"text/plain"[/PHP]

PHP 4.3.11 with UNIX with option --with-magic_mime

[PHP] echo mime_content_type('/images/myimgae.png'); // RETURNS
"text/plain"[/PHP]

PHP 4.3.2 and 4.3.6 with UNIX, PHP 5.0.4 with Windows (w/o magic_mime
support)

[PHP] echo mime_content_type('/images/myimage.png'); // RETURNS
"image/png"[/PHP]

I am having to shut off support within a portable web application that
will be housed, at least, in the following environments:

1. PHP 4.3.2/UNIX
2. PHP 4.1.2/UNIX
3. PHP 4.3.6/UNIX
4. PHP 4.3.11/UNIX
5. PHP 5.0.4/Windows

this means that the environment must be universal for this to work, and
in the case of a few test environments that were running 4.3.11 -
5.0.4, mime_content_type() under PHP supporting --with-magic_mime would
always return
text/plain
and not
image/png

I think this is a bug but cannot independently verify this unless
someone else here duplicates my test, provided they too are running PHP
4.3.8+ with --with-magic_mime support enabled and see if they get the
same results. Otherwise, how do I work around this problem? [Note: I
wrote my own "mime_content_type()" function that works just fine)

Thanx
Phil


Hi

did you try:
// $f is path to file
$f = escapeshellarg($f);
$mimetype = trim( `file -bi $f` );

Maybe that works on all systems. (Not tested)

Regards,
Erwin Moller
Aug 12 '05 #2
I have that in my local "mime_content_type()" function I wrote. But
because this version of PHP (4.3.11) comes with --with-magic_mime
enabled, I am unable to use my version of "mime_content_type()" and am
forced to use theirs.

Phil

Aug 12 '05 #3
Oh one more thing, that does not work on Windows (don't know about Mac
or Solaris), so I'm afraid it doesn't work on all systems. On Windows
you're basically screwed and have to look at the ext and pray it's
true-to-form.

Phil

Aug 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1908
by: Jukka K. Korpela | last post by:
No, I'm not making this up, this is what http://www.w3.org/ says when accessed with a text browser, or in any decent browser in no-images mode: "Tim Berners-Lee smiling 2003-12-31: Buckingham...
4
17563
by: j.t.w | last post by:
Hi All. I'm having a problem with my Date of Birth textbox. When I open the ..htm file, the "DoB" textbox is flat with a border. All of my other textboxes are sunken and are yellow. When I...
10
4673
by: comp.lang.php | last post by:
echo mime_content_type('/var/www/html/video/small.mov'); // 1.5mb Quicktime video returns "video/quicktime" echo mime_content_type('/var/www/html/video/huge.mov'); // 10.5mb Quicktime video...
5
2165
by: Kivak Wolf | last post by:
Hey everyone, I have a textbox in my web page that is going to be used to enter an E-mail into (just plain text, no HTML). Now, this will interact with a SQL database where the contents of the...
7
2282
by: Rich | last post by:
Is the link rel="stylesheet" supposed to be real plain text, or would some word processor format such as Word/Pad work? This sample stylesheet seems garbled if downloaded and opened with...
3
4437
by: Stan Brown | last post by:
Posted by Pierre Blais in the current RISKS Digest: http://catless.ncl.ac.uk/Risks/24.24.html#subj9 -- Stan Brown, Oak Road Systems, Tompkins County, New York, USA http://OakRoadSystems.com/...
3
13919
by: letuce dance | last post by:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> public partial class Default2 : System.Web.UI.Page { protected void Page_Load(object sender,...
2
3566
by: Navodit | last post by:
Hi I am new to Javascript and am not sure what is the difference between the following two statements: <script type="text/javascript"> ..... </script>
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7084
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7278
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5013
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.