cs.punk Posted March 9, 2010 Share Posted March 9, 2010 <?php if(preg_match('/(\.jpeg$ | \.jpg$ | \.gif$)/i', $file_name)) ?> Is it correct? Quote Link to comment https://forums.phpfreaks.com/topic/194652-only-allow-jpeg-jpg-and-gif-is-this-correct-preg-match/ Share on other sites More sharing options...
JAY6390 Posted March 9, 2010 Share Posted March 9, 2010 use this instead /\.(jpe?g|gif)$/i Quote Link to comment https://forums.phpfreaks.com/topic/194652-only-allow-jpeg-jpg-and-gif-is-this-correct-preg-match/#findComment-1023750 Share on other sites More sharing options...
cs.punk Posted March 9, 2010 Author Share Posted March 9, 2010 Thanks dude I appreciate it! This stuff isn't really well documented huh :-\ Quote Link to comment https://forums.phpfreaks.com/topic/194652-only-allow-jpeg-jpg-and-gif-is-this-correct-preg-match/#findComment-1023763 Share on other sites More sharing options...
JAY6390 Posted March 9, 2010 Share Posted March 9, 2010 The easiest method is to learn by practice. Take a look at http://www.regular-expressions.info/ for examples and also this thread http://www.phpfreaks.com/forums/index.php/topic,127902.0.html Quote Link to comment https://forums.phpfreaks.com/topic/194652-only-allow-jpeg-jpg-and-gif-is-this-correct-preg-match/#findComment-1023766 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.