Re: Readdir
| From: | Jochem Maas | Date: | Tue, 28 Nov 2006 09:59:50 +0000 |
| Subject: | Re: Readdir | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-245214@lists.php.net to get a copy of this message | ||
Tom Chubb wrote:
> What would be the best way to retrieve a list of files from an upload
> folder that are called "id" where the extension could be .doc .txt or
> .pdf
> For example, I have a folder where people can upload a document and
> the document is renamed as their user id. They can upload a PDF, DOC
> or TXT file. They may wish to upload one of each. I am using
> file_exists for each case, but is there an easier/tidier way of doing
> it?
> Thanks in advance,
>
> Tom
>
try the glob() function, something like:
$id = getUserId();
foreach (glob("/path/to/user/files/$id.*") as $file) {
echo $file,"<br />";
}