469,281 Members | 2,486 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,281 developers. It's quick & easy.

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
Jul 17 '05 #1
4 34068
Matthew Robinson wrote:
is there a way to check if a file exists using php?


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

Jul 17 '05 #2
"Matthew Robinson" a crit le 07/01/2004 :
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


use function file_exists();

--
Have you read the manual?
http://www.php.net/manual/en/

Jul 17 '05 #3
thanks
Jul 17 '05 #4
On Wed, 07 Jan 2004 19:07:46 +0000, Matthew Robinson wrote:
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


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

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

if (file_exists($filename))
{
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)'.

Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by newcomer | last post: by
10 posts views Thread by Raymond | last post: by
7 posts views Thread by andylcx | last post: by
5 posts views Thread by jez123456 | last post: by
2 posts views Thread by Adrian | last post: by
10 posts views Thread by Ricardo Luceac | last post: by
5 posts views Thread by sword | last post: by
14 posts views Thread by John Salerno | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.