almightyegg Posted April 5, 2007 Share Posted April 5, 2007 <? $file = '/home/lordofth/public_html/images/society/banner'.$clutch[id].'.gif'; if(file_exists($file)){ echo "<img src='http://www.lordoftheabyss.com/images/society/banner$clutch[id].gif'>"; }else{ echo "<img src='http://www.lordoftheabyss.com/images/society/bannerdefault.gif'>"; } The problem I have is that the leader/coleader can upload a new banner, but I don't want to have to restrict it to .gif but in saying that I don't want to have to run 20 different checks for .jpg .png.bmp etc... so is there a variable that I can put like: $file = '/home/lordofth/public_html/images/society/banner'.$clutch[id].'$IMAGE_ENDING'; thanks in advance Link to comment https://forums.phpfreaks.com/topic/45737-image/ Share on other sites More sharing options...
Lumio Posted April 5, 2007 Share Posted April 5, 2007 why don't you save the image-name within the image-type? Link to comment https://forums.phpfreaks.com/topic/45737-image/#findComment-222182 Share on other sites More sharing options...
almightyegg Posted April 5, 2007 Author Share Posted April 5, 2007 why don't you save the image-name within the image-type? I'm not following ??? Link to comment https://forums.phpfreaks.com/topic/45737-image/#findComment-222187 Share on other sites More sharing options...
AndyB Posted April 5, 2007 Share Posted April 5, 2007 so is there a variable that I can put like: $file = '/home/lordofth/public_html/images/society/banner'.$clutch[id].'$IMAGE_ENDING'; Why don't you save the filename and extension together, for example: $clutch[id] = happyface.gif or happyface.jpg, etc. then you can forget about the $IMAGE_ENDING altogether. Link to comment https://forums.phpfreaks.com/topic/45737-image/#findComment-222195 Share on other sites More sharing options...
almightyegg Posted April 5, 2007 Author Share Posted April 5, 2007 because $clutch[id] is the id of each group, it is used to distinguis between different images uploaded and to link around the groups link.php?id=$clutch[id] Link to comment https://forums.phpfreaks.com/topic/45737-image/#findComment-222198 Share on other sites More sharing options...
AndyB Posted April 5, 2007 Share Posted April 5, 2007 because $clutch[id] is the id of each group, it is used to distinguis between different images uploaded and to link around the groups link.php?id=$clutch[id] Then what on earth might '$IMAGE_ENDING' be? This is all too cryptic for me. Link to comment https://forums.phpfreaks.com/topic/45737-image/#findComment-222599 Share on other sites More sharing options...
almightyegg Posted April 9, 2007 Author Share Posted April 9, 2007 $IMAGE_ENDING = .bmp, .png, .jpg etc.... Link to comment https://forums.phpfreaks.com/topic/45737-image/#findComment-225305 Share on other sites More sharing options...
almightyegg Posted April 10, 2007 Author Share Posted April 10, 2007 could I do thisby setting an array? $image_ending = array(info that I'm not quite sure of) ?? Link to comment https://forums.phpfreaks.com/topic/45737-image/#findComment-225688 Share on other sites More sharing options...
almightyegg Posted April 10, 2007 Author Share Posted April 10, 2007 $image_ending = array('png', 'gif', 'jpg', 'jpeg', 'bmp'); $file = '/home/lordofth/public_html/images/players/m'.$mem[id].'.$image_ending'; WOuld that work guys? Link to comment https://forums.phpfreaks.com/topic/45737-image/#findComment-225850 Share on other sites More sharing options...
Lumio Posted April 10, 2007 Share Posted April 10, 2007 no... you have to save somewhere else the filetype. Link to comment https://forums.phpfreaks.com/topic/45737-image/#findComment-225896 Share on other sites More sharing options...
almightyegg Posted April 10, 2007 Author Share Posted April 10, 2007 can you elaborate on that? I'm not following Link to comment https://forums.phpfreaks.com/topic/45737-image/#findComment-226051 Share on other sites More sharing options...
Lumio Posted April 11, 2007 Share Posted April 11, 2007 Someone uploades a file, right? Now you got a filename like my_picture.jpg. So let's put that string into a variable and filter the type of it (.jpg): <?php $file = 'my_picture.jpg'; preg_match('{(\.[\w\d]+)$}', $file, $match); $file_type = $match[1]; // result: .jpg ?> Now you can save $file_type in your mysql an write it out, like the filename Link to comment https://forums.phpfreaks.com/topic/45737-image/#findComment-226650 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.