28, May 2012

best way to get the mime-type from a file - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: best way to get the mime-type from a file
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: best way to get the mime-type from a file  (Read 1681 times)
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« on: Aug 31, 2006, 04:01:57 pm »

Hello,

Just tried to get the mime-type for a file to use this information in my e-mail class.

First I like to use the the function mime_content_type() but this is not supoorted on all shared hosting services, another one is with help of the exif module but this also limited on some machines. To get the type for an image can be done with getimagesize(), but how to get this information for other files type (zip, doc, xls etc...)

who knows a diff. way?

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #1 on: Aug 31, 2006, 04:10:55 pm »

I guess system() wont work on shared hosting either, but you can check this :

Code:
<?php
if ( ! function_exists 'mime_content_type ' ) )
{
   function 
mime_content_type $f )
   {
       return 
system trim'file -bi ' escapeshellarg $f ) ) ) ;
   }
}
?>


Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #2 on: Aug 31, 2006, 04:17:58 pm »

Thank, you I saw this code in the manual, but I think its not possible to use for all this people with cheap (and bad) hosting services... I think it's OK to use only a "automatic" mimetypes for images and default octet-stream for attachments.

In phpmailer you have to define all mime types...

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #3 on: Aug 31, 2006, 04:20:22 pm »

It is very time consuming and difficult to make your own function for this....

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: Aug 31, 2006, 04:28:22 pm »

It is very time consuming and difficult to make your own function for this....
you again Cheesy
I know but I need only a custom class to send e-mails by my other classes clases (access_user, db_cart) there is no need to build complete e-mail applications. I think about to skip smtp functions because php mailer works fine there...

(at the end i'm almost ready...)Wink

Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=3913
Tags : php hosting shared hosting Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: best way to get the mime-type from a file
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 04:03:35 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.