Posted by pangea33 on 12/02/06 23:28
bill wrote:
> I have a directory into which I upload pictures. I know the
> entire file name other than the extension.
>
> file_exists will return true when I give it a wildcard extension,
> but I can't figure out the best way to determine the extension
> for fopen.
>
> I sure don't want to troll through the entire directory with
> readdir.
>
> I would appreciate suggestions.
>
> bill
If you use the "find" command with exec() you can get a list of files
that match your criteria. Essentially using the filename you already
know, and then a wildcard for the extension...
find /var/www/directory/pics2 -name "weddingphoto.*"
For me this outputs: /var/www/directory/pics2/weddingphoto.jpg
If you output the results into a file or into a variable, you can then
parse it for whatever is relevent to you.
find /var/www/directory/pics2 -name "weddingphoto.*" >
/var/www/directory/pics2/results.txt
Navigation:
[Reply to this message]
|