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"; } } } ?> Link to comment https://forums.phpfreaks.com/topic/159394-solved-adding-path/ 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? ??? Link to comment https://forums.phpfreaks.com/topic/159394-solved-adding-path/#findComment-840744 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)) { Link to comment https://forums.phpfreaks.com/topic/159394-solved-adding-path/#findComment-840754 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 Link to comment https://forums.phpfreaks.com/topic/159394-solved-adding-path/#findComment-840810 Share on other sites More sharing options...
fullyloaded Posted May 23, 2009 Author Share Posted May 23, 2009 that worked great thanks.... Link to comment https://forums.phpfreaks.com/topic/159394-solved-adding-path/#findComment-840881 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 $. Link to comment https://forums.phpfreaks.com/topic/159394-solved-adding-path/#findComment-840887 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.