Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Sep 2008
    Posts
    116
    Thanks
    1
    Thanked 0 Times in 0 Posts

    how to check images on if statement?

    Hi guys,

    I need your help, I want to create a filename for the image on the webpage and I also want to out how I can check on the if statement to see if the image on the webpage is exist.

    Code:
    $image1 = <div id="image1" style="position:absolute; overflow:hidden; left:415px; top:157px; width:114px; height:81px; z-index:0"><img src="/images/tvguide_blue.jpg" alt="" title="" border=0 width=114 height=81></div>

    On the webpage, it display as "$image =". Does anyone know how i can create a function for a filename so I can write something like this:

    Code:
    if ($image = exist) { 
      // do something
    }
    Does anyone have any idea?

    thanks in advance

  • #2
    Regular Coder
    Join Date
    Jul 2012
    Location
    London
    Posts
    473
    Thanks
    4
    Thanked 86 Times in 86 Posts
    Quote Originally Posted by mark103 View Post
    Hi guys,

    I need your help, I want to create a filename for the image on the webpage and I also want to out how I can check on the if statement to see if the image on the webpage is exist.

    Code:
    $image1 = <div id="image1" style="position:absolute; overflow:hidden; left:415px; top:157px; width:114px; height:81px; z-index:0"><img src="/images/tvguide_blue.jpg" alt="" title="" border=0 width=114 height=81></div>

    On the webpage, it display as "$image =". Does anyone know how i can create a function for a filename so I can write something like this:

    Code:
    if ($image = exist) { 
      // do something
    }

    Does anyone have any idea?

    thanks in advance
    PHP Code:
    $file '/path/to/foo.txt'// 'images/'.$file (physical path)

    if (file_exists($file)) {
        echo 
    "The file $file exists";
    } else {
        echo 
    "The file $file does not exist";

    If the image path exists or if the image has been displayed on the webpage?

  • #3
    Regular Coder
    Join Date
    Sep 2008
    Posts
    116
    Thanks
    1
    Thanked 0 Times in 0 Posts
    yes, i want to check if the image has been displayed on the webpage.

    I want to check the image using with this statement:

    Code:
    if (e.keyCode == '38') {
           window.alert('up arrow')
        }

    Do you have any idea how i can check if the image has been displayed on the webpage?

  • #4
    Regular Coder
    Join Date
    Mar 2012
    Posts
    168
    Thanks
    5
    Thanked 11 Times in 11 Posts
    Quote Originally Posted by mark103 View Post
    yes, i want to check if the image has been displayed on the webpage.

    I want to check the image using with this statement:

    Code:
    if (e.keyCode == '38') {
           window.alert('up arrow')
        }

    Do you have any idea how i can check if the image has been displayed on the webpage?
    You could pass a value through a POST or GET variable that the page will display an image?

    Or you can have a variable $displayed and as the page renders, if a specific image is loaded you set $displayed to true.

    Otherwise I'm not sure how you could implement this... You may get better results in the PHP section.

  • #5
    New Coder
    Join Date
    Jan 2013
    Posts
    71
    Thanks
    3
    Thanked 2 Times in 2 Posts
    You can try this one.

    $file = '/path/to/foo.txt'; // 'images/'.$file (physical path)

    if (file_exists($file)) {
    echo "The file $file exists";
    } else {
    echo "The file $file does not exist";
    }


  •  

    Posting Permissions

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