Jump to content

[SOLVED] 2 image questions/problems


almightyegg

Recommended Posts

Image question 1

 

I want all my members to log on and all have the same default image called default.jpg and if they upload a new image then it is called userid.jpg (must be jpg) how would I do a search to see if there was an image called $mem[id].jpg and if there isn't show default.jpg?

 

Image question 2

 

Each member also has a main image which is set in the site as the same one, but with different colours etc. But in the site they can add things to the image eg. they click that they want a bandana and it adds it to the image.I know it's possible but I don't know whether it is in php...My limits are php html and css

 

Thanks for reading

Link to comment
Share on other sites

For question one, you might consider looking at http://us2.php.net/manual/en/function.file-exists.php.

 

The first example provided might do what you need.

 

$file = '/images/players/a$mem[id].jpg';

if(file_exists($file)){
echo "<img src='http://www.lordoftheabyss.com/images/players/a$mem[id].jpg'>";
}else{
echo "<img src='http://www.lordoftheabyss.com/images/players/default.jpg'>";
}

 

There is a file called a1.jpg (my id is 1) and yet it still doesn't show :(

 

For question 2:

 

http://www.php.net/manual/en/ref.image.php

 

You will need to have PHP's GD library installed.

Thanks I'll take a look :)

Link to comment
Share on other sites

Still didn't work...is there any other errors on my code:

$file = 'http://www.lordoftheabyss.com/images/players/a$mem[id].jpg';

if(file_exists($file)){
echo "<img src='http://www.lordoftheabyss.com/images/players/a'.$mem[id].'.jpg'>";
}else{
echo "<img src='http://www.lordoftheabyss.com/images/players/default.jpg'>";
}

Link to comment
Share on other sites

Oops! :P I'm slow

alas, no joy still though.

$file = 'http://www.lordoftheabyss.com/images/players/a'.$mem[id].'.jpg';

if(file_exists($file)){
echo "<img src='http://www.lordoftheabyss.com/images/players/a'.$mem[id].'.jpg'>";
}else{
echo "<img src='http://www.lordoftheabyss.com/images/players/default.jpg'>";
}

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.