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 :
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
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