fullyloaded Posted May 23, 2009 Share Posted May 23, 2009 hey is there anyway to change this code<?php $file = $poster['avatar']; to this? <?php $file = (hxxp://www.mysitehere.com/uploads/) $poster['avatar']; where it will use the path i put in and the $poster['avatar']; <?php $file = $poster['avatar']; if (!preg_match("/^.*\.gif/",$file)) { if (!preg_match("/^.*\.jpg/",$file)) { if (!preg_match("/^.*\.png/",$file)) { $poster['avatar'] = "templates/{$pageInfo['theme']}/images/noavatar.gif"; } } } ?> Quote Link to comment Share on other sites More sharing options...
waynew Posted May 23, 2009 Share Posted May 23, 2009 Em: $file = "hxxp://www.mysitehere.com/uploads/".$poster['avatar']; Is that what you were asking for? ??? Quote Link to comment Share on other sites More sharing options...
fullyloaded Posted May 23, 2009 Author Share Posted May 23, 2009 yes that worked great thanks a lot im having one more problem when some of my members upload a photo it will save the image name in the database like this image.JPG and not like this image.jpg is there away to add the .JPG in caps to this code aswell? i tried adding this line of code if (!preg_match("/^.*\.JPG/",$file)) { but its conflicting if (!preg_match("/^.*\.gif/",$file)) { if (!preg_match("/^.*\.jpg/",$file)) { if (!preg_match("/^.*\.png/",$file)) { Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted May 23, 2009 Share Posted May 23, 2009 those three lines can be merged together into if (!preg_match("/^.*\.(gif|jpg|png)/i",$file)) { That will match files ending in .gif .jpg or .png. It will also be case-insensitve Quote Link to comment Share on other sites More sharing options...
fullyloaded Posted May 23, 2009 Author Share Posted May 23, 2009 that worked great thanks.... Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted May 23, 2009 Share Posted May 23, 2009 Should be if (!preg_match("/^.*\.(gif|jpg|png)$/i",$file)) { though. Otherwise e.g. foo.jpg.bar would match as well (note the added $. Quote Link to comment 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.