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 Quote Link to comment 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? Quote Link to comment 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 ??? Quote Link to comment 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. Quote Link to comment 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] Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
almightyegg Posted April 9, 2007 Author Share Posted April 9, 2007 $IMAGE_ENDING = .bmp, .png, .jpg etc.... Quote Link to comment 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) ?? Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment 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 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.