Vivid Lust Posted July 17, 2008 Share Posted July 17, 2008 I have part of my code: if(strstr($ourfile,".jpg")!=".jpg") { $error = "<font color=red>File type not allowed</font>"; } Can someone tell me how i can add more image types onto that to "allow". Thanks in advanced! Quote Link to comment https://forums.phpfreaks.com/topic/115241-solved-php-image-type-help/ Share on other sites More sharing options...
JD* Posted July 17, 2008 Share Posted July 17, 2008 If you're familiar with them, you could use an array to define the proper types, then get the extension and do an in_array search to see if it matches. Quote Link to comment https://forums.phpfreaks.com/topic/115241-solved-php-image-type-help/#findComment-592487 Share on other sites More sharing options...
.josh Posted July 17, 2008 Share Posted July 17, 2008 Well here's one way... <?php // allowed extensions $allowed = array('.jpg','.gif','.bmp'); $ext = substr($ourfile, -4); if(!in_array($ext, $allowed)) { $error = "<font color=red>File type not allowed</font>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/115241-solved-php-image-type-help/#findComment-592488 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.