Page 1 of 1

searching a directory for a image

Posted: Wed Nov 20, 2002 2:38 pm
by penguinboy
okay i need help searching for an image

i'm trying to search with an "*"
but its not working

basically i'm looking for any file that ends in
_$_GET[DNID]_p1

so it could be

1_2_p1
2_2_p1
89_2_p1
bob_2_p1
smelly_bob_2_p1


$img1 = "*_$_GET[DNID]_p1";


if(file_exists("$img1"))
{print("<a href=\"javascript:popUp('$img1')\">&nbsp;&nbsp;<img src='$img1' width='150' height='150' border=0></a>");}

else
{print("&nbsp;&nbsp;<a href=\"javascript:popUp('up.php?P=p1&W=def')\">Upload Image 1</a>&nbsp;&nbsp;");}

Posted: Thu Nov 21, 2002 2:29 am
by twigletmac
AFAIK you can't use wildcards like '*' with file_exists().

Mac

Posted: Thu Nov 21, 2002 2:15 pm
by superwormy
Are you on a Linux server? You could use something like this:

shell_exec ("find ... [filename and params here, see man find under linux]");


And then print those results. Might also be worth looking into putting info into database, ie name the images just by the record Index in the database, then search the database.

Posted: Fri Nov 22, 2002 2:01 am
by twigletmac
You could also loop through the directory and use a regular expression to find matches:

http://www.php.net/manual/en/ref.dir.php
http://www.php.net/manual/en/ref.pcre.php

Mac