PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
//ARRAY OF FILE NAMES ON MY SERVER:
$a_doc = array('test.doc','htmfile.htm','myimage.jpg');
$doc_root = '/myfilefolder/';
foreach($a_doc as $ak => $docName){
//IS FILE IMAGE:
if(is_array(getimagesize($doc_root.$docName))){
echo $docName.' is an image<BR>';
}else{
//IF THE FILE ISN'T AN IMAGE WHAT IS IT?????
}
}
?>
yeah.. binary files can be literally anything.. but, the bulk of binary files are a specific format structure.. you'll just need to find the formatting template for their binary pattern to determine their type.. this is a lot of work.. so it can be very painful..
Yeah it is, and honestly I'm thinking more then I need to. In reality if a user does upload a "bad" file I will know who the user is. I just wanted to display an image next to the file type coinciding with the file type.
I'm thinking the best way to do this is capture the mime file type when the user uploads the file and store it in a table. I'll just call it from there.