Jump to content

.image


almightyegg

Recommended Posts

<?
$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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.