24, July 2008

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

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ 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

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


It's time to use PHP5!


« on: Aug 31, 2006, 05: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?


Last blog : 4th of July Lottery from TemplateMonster.com
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7975
40807 credits
Members referred : 3



« Reply #1 on: Aug 31, 2006, 05: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 Visit through proxy

Last blog : MIA - Where Nick and Tim
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6280
38506 credits
Members referred : 374


It's time to use PHP5!


« Reply #2 on: Aug 31, 2006, 05: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...


Last blog : 4th of July Lottery from TemplateMonster.com
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7975
40807 credits
Members referred : 3



« Reply #3 on: Aug 31, 2006, 05: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 Visit through proxy

Last blog : MIA - Where Nick and Tim
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6280
38506 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: Aug 31, 2006, 05: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


Last blog : 4th of July Lottery from TemplateMonster.com
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....

Topic sponsors:
Get a permanent link here for $1.99!


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?
Jul 24, 2008, 11:27:41 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!


Forum Statistics
Total Posts: 35.717
Total Topics: 7.379
Total Members: 3.710
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: prolist

50 Guests, 3 Users online :

11 users online today:



Readers

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