Ninjakreborn Posted February 2, 2007 Share Posted February 2, 2007 I had a file handling program I built awhile back but ended up losing over time. Now I have this half system to validate filetypes. Is there a good/proven method that is really powerful that anywhere here uses to validate there filetypes. Just a specific method that you have used for a long time, and you know work's really well. I am going to come up with my own again, I just want some idea's on how to formulate it. Thanks? Quote Link to comment https://forums.phpfreaks.com/topic/36775-solved-checking-filetypes/ Share on other sites More sharing options...
HuggieBear Posted February 2, 2007 Share Posted February 2, 2007 If it's just images and you're using PHP >= 4.3.0 then just use getimagesize() as this returns the mime-type of the image. Regards Huggie Quote Link to comment https://forums.phpfreaks.com/topic/36775-solved-checking-filetypes/#findComment-175404 Share on other sites More sharing options...
Ninjakreborn Posted February 2, 2007 Author Share Posted February 2, 2007 So something like. <?php $accepted_types = array("gif", "jpg", "jpeg", "bmp"); if (!get_image_size($filename, $accepted_types) { // not allowed }else { // do file stuff } ?> Is that about along the lines of what you mean? Quote Link to comment https://forums.phpfreaks.com/topic/36775-solved-checking-filetypes/#findComment-175408 Share on other sites More sharing options...
Ninjakreborn Posted February 2, 2007 Author Share Posted February 2, 2007 $i=@getimagesize($_FILES['logo']['tmp_name']); if (($i[2]==1) or ($i[2]==2) or ($i[2]==3)) { # OK } else { # FAILS } I found this example. Is this flawless or is there something else that need's to be done with it? Quote Link to comment https://forums.phpfreaks.com/topic/36775-solved-checking-filetypes/#findComment-175415 Share on other sites More sharing options...
Ninjakreborn Posted February 2, 2007 Author Share Posted February 2, 2007 Got it $i=@getimagesize($_FILES['logo']['tmp_name']); if (($i[2]==1) or ($i[2]==2) or ($i[2]==3) or ($i[2]==6)) { Thanks Quote Link to comment https://forums.phpfreaks.com/topic/36775-solved-checking-filetypes/#findComment-175427 Share on other sites More sharing options...
Ninjakreborn Posted February 2, 2007 Author Share Posted February 2, 2007 Do I check for 'name' or 'tmp_name' When I run this? Quote Link to comment https://forums.phpfreaks.com/topic/36775-solved-checking-filetypes/#findComment-175449 Share on other sites More sharing options...
Ninjakreborn Posted February 2, 2007 Author Share Posted February 2, 2007 Nevermind, I got it again. Quote Link to comment https://forums.phpfreaks.com/topic/36775-solved-checking-filetypes/#findComment-175456 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.