SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Mar 2007
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP IMG Link Checker

    Hello,

    I was wondering if someone could give me a tutorial on this certain topic:

    I have members for my website, however, I want them to be able to add their own avatar to their profile. Each member is a USER, which had their own ID. The IDs are automatically created when a user signs up for my website.

    Basically I want every user to have a default avatar, so lets say USER0 can be the IMG USER0.jpg - And it would show the default avatar or default image.

    Now I want a PHP IMG LINK Checker to do this:

    ECHO (LETS SAY) USER22 and I simply add the extension .jpg - so it would be USER22.jpg

    Example of the code I want is this:

    ECHO USER22.jpg
    IF USER22.jpg is invald
    ECHO USER00.jpg - Which is default IMG.

    I could put an upload script, but then it wouldn't make sense as I would have to manually verify them anyway as someone could upload a nude pic or something retarded or racist, basically against our terms. I'd rather have them e-mail me their custom avatar if they wish to use a custom one.

    I'm sure this is an easy script, but I'm a newb, haha.

    Thanks,
    Jon

  2. #2
    SitePoint Addict silentcollision's Avatar
    Join Date
    Jun 2006
    Location
    New Zealand
    Posts
    388
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I'm reading your question correctly...

    file_exists()

    PHP Code:
    $img "USER22.jpg";
    if(
    file_exists($img)) {
     echo 
    "$img";
    } else {
     echo 
    "USER00.jpg";


  3. #3
    SitePoint Member
    Join Date
    Mar 2007
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by silentcollision View Post
    If I'm reading your question correctly...

    file_exists()

    PHP Code:
    $img "USER22.jpg";
    if(
    file_exists($img)) {
     echo 
    "$img";
    } else {
     echo 
    "USER00.jpg";

    It works, however, is there any way I can set the param not as full path, currently, it only works as full path.

    PHP Code:
            <?
    $user 
    $vInfo[$TbUsers->col_Id];
    $img "/home/user/public_html/images/avatar/$user.jpg";
    if(
    file_exists($img)) {
     echo 
    "$img";
    } else {
     echo 
    "<img src='/images/default.jpg' alt='' width='40' height='60' border='0'>";

                        
    ?>
    $user works and assigns the USERIDs are mentioned above. You can see that $user is within $img but it needs the full path? Why is that? I tried my URL as well, and it just ELSES to the default logo.

  4. #4
    SitePoint Member
    Join Date
    Mar 2007
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I figured it out!

    PHP Code:

    <?
    $user 
    $vInfo[$TbUsers->col_uId];
    $img "/home/user/public_html/images/avatar/$user.jpg";
    if(
    file_exists($img)) {
     echo 
    "/images/avatar/$user.jpg";
    } else {
     echo 
    "/images/logo.jpg";

                        
    ?>
    Thank you!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •