cs.punk Posted March 9, 2010 Share Posted March 9, 2010 <?php if(preg_match('/(\.jpeg$ | \.jpg$ | \.gif$)/i', $file_name)) ?> Is it correct? 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 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 :-\ 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 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
Archived
This topic is now archived and is closed to further replies.