Page 1 of 1

Wildcard in file_exists()

Posted: Tue Nov 04, 2003 4:19 pm
by jkpolsar
Hi all,

I just had a quick question on how I could solve this problem...

I'm creating a module for someone that will upload movies to their server. Before the upload, the script checks to see if any other similarly named movies are on the server and adds a number after the filename in order to not overwrite it (e.g. movie_1.mov, movie_2.mov, movie_3.mov, etc).

When checking it with file_exists(), I'd like to check for files with ANY extension with that name (e.g. check for movie_1.mp4, movie_1.asf, movie_1.*).

file_exists($mov_location . "/" . $mov_prefix . "_" . $move_next . ".mov");

I basically need the ".mov" above to be a wildcard.

Any help would be greatly appreciated!

Posted: Tue Nov 04, 2003 8:50 pm
by volka
depends on your version of php wether there is such a built-in function or not.
Take a look at http://php.net/glob
If there's no such function you have to iterate the directory's filenames yourself.