Check if a file exists

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matthew Robinson

    Check if a file exists

    is there a way to check if a file exists using php? i want to check if a
    picture exists, and if not, use a picture saying that the picture couldn't
    be found.

    TIA
  • Jim Dabell

    #2
    Re: Check if a file exists

    Matthew Robinson wrote:
    [color=blue]
    > is there a way to check if a file exists using php?[/color]

    It's quicker to look in the manual yourself than post a question here and
    wait for an answer.

    <URL:http://www.php.net/manual/en/function.file-exists.php>


    --
    Jim Dabell

    Comment

    • Jedi121

      #3
      Re: Check if a file exists

      "Matthew Robinson" a écrit le 07/01/2004 :[color=blue]
      > is there a way to check if a file exists using php? i want to check if a
      > picture exists, and if not, use a picture saying that the picture couldn't
      > be found.
      >
      > TIA[/color]

      use function file_exists();

      --
      Have you read the manual?


      Comment

      • Matthew Robinson

        #4
        Re: Check if a file exists

        thanks

        Comment

        • adamt

          #5
          Re: Check if a file exists

          On Wed, 07 Jan 2004 19:07:46 +0000, Matthew Robinson wrote:
          [color=blue]
          > is there a way to check if a file exists using php? i want to check if a
          > picture exists, and if not, use a picture saying that the picture couldn't
          > be found.
          >
          > TIA[/color]

          I've been using something along the lines of this:

          $filename=($dbr ow['hexid'] . ".jpg");

          if (file_exists($f ilename))
          {
          printf("<img src=\"%s.jpg\" alt=\"%s\" />\n<br />", $dbrow["id"],
          $dbrow["name"]);
          }
          else
          {
          printf("<img src=\"notfound. jpg\" alt=\"no image available\" />\n<br />");
          }

          Which is probably not a very elegant way of doing things, but it 'works
          for me(tm)'.

          Comment

          Working...