473,651 Members | 2,995 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mime_content_ty pe() for PNG image returns "text/plain"

PHP 4.3.8 with UNIX with option --with-magic_mime

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

PHP 4.3.11 with UNIX with option --with-magic_mime

[PHP] echo mime_content_ty pe('/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_ty pe('/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_ty pe() 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_t ype()" function that works just fine)

Thanx
Phil

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

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

PHP 4.3.11 with UNIX with option --with-magic_mime

[PHP] echo mime_content_ty pe('/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_ty pe('/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_ty pe() 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_t ype()" 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_t ype()" 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_t ype()" 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
1920
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 Palace today announced that Queen Elizabeth II will make Tim Berners-Lee, W3C Director, a Knight Commander of the Order of the British Empire (KBE)." Actually, I could see the point of title="Tim Berners-Lee smiling", since it's not obvious to...
4
17578
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 change the name of the "DoB" textbox to something like "Telephone" or "TelephoneBirthdate", the textbox changes to sunken, and yellow. I have tried changing the name to "DBirth", "BirthDate", "Birthday", "cusBirth", "DOBirth", etc. but, the...
10
4704
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 returns "text/plain" Environment: PHP 5.0.4 - Windows XP --enable-mime-magic PHP 4.3.11 - Fedora Core 4 --enable-mime-magic
5
2178
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 textbox are sent from the SQL database to the textbox, then the user edits it, and then the text inside the textbox is sent back to the SQL database. I did it the same way as if i had used a VarChar instead of a type "text" variable in the SQL...
7
2297
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 Notepad, but seems to view right in browser. Could this be a problem, or cause slow loading when applied? A link for this sample "style.css" is on http://users.ntplx.net/~richw/ Thanks for any advice, Rich
3
4454
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/ HTML 4.01 spec: http://www.w3.org/TR/html401/ validator: http://validator.w3.org/ CSS 2.1 spec: http://www.w3.org/TR/CSS21/ validator: http://jigsaw.w3.org/css-validator/
3
13933
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, EventArgs e) { Response.ContentType = "text/plain"; Response.Write("help"); }
2
3582
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
8361
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8278
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8807
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8701
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8584
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4144
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4290
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1912
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1588
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.