Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get mime types of MAC files

Status
Not open for further replies.

Sleidia

Technical User
May 4, 2001
1,284
FR
Hello :)

I've written a simple script whose task is to allow registered members to upload files with allowed mime types in their own folder. Allowed extensions are : txt, doc, pdf, jpeg, gif.

The code is as follow :

Code:
<?php

if($_FILES['form_comp_file_pic']['name'] != "") {
		if(stristr($_FILES['form_comp_file_pic']['type'], 'jpg') OR stristr($_FILES['form_comp_file_pic']['type'], 'jpeg')) {
		$file_ext_pic = "jpg";
		} else if(stristr($_FILES['form_comp_file_pic']['type'], 'gif')) {
		$file_ext_pic = "gif";
		} else {
		show_errors(NULL, "form_comp_file_pic", 0);
		}
		
$up_file = $form_comp_file_pic;
$up_filename = $comp_ID . "_pic." . $file_ext_pic;
@copy($up_file, "$up_dir/$up_filename") or die();
$form_comp_file_pic = $up_filename;
$field_list .= " . comp_file_pic";		
		
} else {
}

if($_FILES['form_comp_file_rules']['name'] != "") {
		if(stristr($_FILES['form_comp_file_rules']['type'], 'texte')) {
		$file_ext_rules = "txt";
		} else if(stristr($_FILES['form_comp_file_rules']['type'], 'msword')) {
		$file_ext_rules = "doc";
		} else if(stristr($_FILES['form_comp_file_rules']['type'], 'pdf')) {
		$file_ext_rules = "pdf";
		} else {
		show_errors(NULL, "form_comp_file_rules", 0);
		}
		
$up_file = $form_comp_file_rules;
$up_filename = $comp_ID . "_rules." . $file_ext_rules;
@copy($up_file, "$up_dir/$up_filename") or die();
$form_comp_file_rules = $up_filename;
$field_list .= " . comp_file_rules";
		
} else {				
}

?>

Now, since I don't have a MAC to test it, I'd want to make sure that the script can work on a MAC. I think I've read somewhere that MAC mime types can be hidden in a way that prevnts PHP from reading them ... but I'm not sure about that.

Any insight anyone?

Thanks :)
 
Hi,
this might be a bad idea, so dont shoot me.
But, if you view source of an image, there are something defining what type it is.

If you open a .gif in notepad, it says GIF89 or something.
If you open a .jpg in notepad, it says JFIF or something..
ps. I dont know if the 89 after GIF is some kind of integer, saying what type of gif it is, or if it's simply what it's called.

I however think that this is in the mac files too?

Olav Alexander Mjelde
Admin & Webmaster
 
this link points to a fairly comphrehensive list of mime types, perhaps you could take what you need from there to cover the bases that you want to

Bastien

Cat, the other other white meat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top